google-sheetsweb-scrapinggoogle-appsgoogle-financexml-import

Use cell reference inside google spreadsheet function


I am using Google Spreadsheet function. This formula works fine.

=ImportXML("https://www.google.com/finance?q=SHA:000001", "//span[@class='pr']")

The string SHA:000001 is contained in cell B4. I would like to use cell reference. So, I changed to formula to

=ImportXML("https://www.google.com/finance?q=" + B4, "//span[@class='pr']")

Unfortunately, this did not work. The value returned is #VALUE!. How should the correct formula look like?


Solution

  • You need to use an ampersand not a plus sign:-

    =ImportXML("https://www.google.com/finance?q="&B4, "//span[@class='pr']")