Reputation: 101
I would like to include a variable in a Google search URL. The URL, at present is:
IE.Navigate "https://www.google.com/search?q=DNR-12-1G+$+Price"
How would I replace the emboldened URL text with a defined string variable such as "pn"? Thanks
Upvotes: 0
Views: 4436
Reputation: 4356
To use a variable all you need is to substitute the text with it
IE.Navigate "https://www.google.com/search?q=" & pn & "+$+Price"
That would do the job. If you wanted to use the content of a cell, either set pn to the cell value like this:
pn = ThisWorkbook.Worksheets(1).Range("A1").Value
Adjust as necessary for your worksheet and cell address... or refer to it directly in the Navigate
step:
IE.Navigate "https://www.google.com/search?q=" & ThisWorkbook.Worksheets(1).Range("A1").Value & "+$+Price"
Upvotes: 1