Run formula from different sheet

0

Can you run formulas from different sheets? (not simply showing the formula as a string/static text)

Say I type

=Sheet1!A1

where in that cell I have a formula

=concatenate(ice&cream)

Here's what I want to see as a result

icecream

But instead of this, I get the same =concatenate(ice&cream) function as a text string.

In my particular case the concatenate function creates an IMPORTXML formula from these 3 columns:

Column 1 (B5):

IMPORTXML(url,"//*/div[2]/div[1]/div/div/div[

Column 2 (C5):

1

Column 3 (D5):

]/div/div/div[1]/h4/a/@href")

Column 4 (E5):

=CONCATENATE("=", B5, C5, D5)

And returns as a result:

=IMPORTXML(url,"//*/div[2]/div[1]/div/div/div[ 1 ]/div/div/div[1]/h4/a/@href")

which extracts a piece of data from http://website.com. I need the IMPORTXML formula to run and give me the piece of data, not return the same formula as static text.

NOTE: I use Google Sheets so the simpler the answer the better (i.e. no macros or other tools if possible) Thank you

Duraid

Posted 2015-05-18T20:21:13.773

Reputation: 17

post the exact formula that you are using to construct IMPORTXML. – teylyn – 2015-05-18T20:41:16.940

Column 1 (B5): IMPORTXML(Members!C2,"//*/div[2]/div[1]/div/div/div[ Column 2 (C5): 1 Column 3 (D5): ]/div/div/div[1]/h4/a/@href") Column 4 (E5): =CONCATENATE("=", B5, C5, D5) – Duraid – 2015-05-18T20:50:49.623

Please don't use a comment for that. Update your question. – teylyn – 2015-05-18T21:08:07.867

I did. Check again – Duraid – 2015-05-18T21:11:50.200

1What you're looking for seems to be the equivalent to excel's Eval(), but Google sheets have no equivalent. Lots of history behind it according to a few Google hits and SO questions – panhandel – 2015-05-18T21:35:57.037

Answers

0

The syntax for the Google Spreadsheet function IMPORTXML is

IMPORTXML(URL, xpath_query)

If you want to keep these parameters dynamic and feed them into the formula from other cells, then you will need something like

=Importxml(A1,A2&A3)

i.e. the string parameters are in the cells, but not the function name. Concatenate will always return a string, never a function. Concatenate is also always more to type than the simple & operator that does the same thing.

teylyn

Posted 2015-05-18T20:21:13.773

Reputation: 19 551

Nice one, haven't thought of formulating it this way. However, I still can't get the desired result because as you said in your answer, concatenate will always return a string and not a function. And the issue here is that the A1 cell in =Importxml(A1,A2&A3), in my case, has a function in it. Do you know of any way around this? (and still keep the function) – Duraid – 2015-05-18T21:23:05.267

Read my last paragraph again. You can't put the function name inside a concatenate. And you don't need to. It will never work. Use the cell references to the *parameters* inside the function. – teylyn – 2015-05-18T21:55:07.280