kenitech
kenitech

Reputation: 1163

How do I use a Cell value inside of a string?

I have the following in my Google Sheet to pull number of views from a YouTube page:

=IMPORTXML("https://www.youtube.com/watch?v=i1D8XIIvYS0","//div[@class='watch-view-count']")

I'd like to split out the YouTube ID into a different column and do the following where B2 is the cell with the value 'i1D8XIIvYS0'

=IMPORTXML("https://www.youtube.com/watch?v=B2","//div[@class='watch-view-count']")

How do I escape 'B2' so that the value is used here?

Upvotes: 0

Views: 64

Answers (2)

Aurielle Perlmann
Aurielle Perlmann

Reputation: 5509

=IMPORTXML("https://www.youtube.com/watch?v="&B2,"//div[@class='watch-view-count']")

If your referencing b2 you just need to remove the quote from after it to in front of it and use the & to join the value with the string

Upvotes: 1

Ed Nelson
Ed Nelson

Reputation: 10259

Try:

=IMPORTXML("https://www.youtube.com/watch?v="& B2 &"","//div[@class='watch-view-count']")

Upvotes: 0

Related Questions