0

I'm working on a little project which would allow me to pull some searches directly from a website without actually opening the webpage.

To get to the end of it, I need my VBA code to automatically open a drop-down list which contains some elements based on previous alerts / searches I has previously set up.

Is there a way, when using getelement.id("[xx]") to refer to a cell (say B2 for example) so that [xx] automatically picks the value in cell B2? (i.e. if my cell B2 contains "Screen1" the code would do getelement.id("Screen1"))

Many thanks

  • Many things are not clear in your description of the issue. You said,' without actually opening the webpage'. Are you using `XmlHttpRequest`? We are not sure what kind of site you are trying to automate and how the dropdown got generated without opening the site? If possible then try to post a sample VBA code and HTML for the dropdown. If possible please try to provide detailed information about it may help us to understand the issue in a better way. – Deepak-MSFT Dec 30 '20 at 06:07

1 Answers1

0

Yes you can:

1- By saving the cell value in a variable

Dim miCellVal as string
miCellVal= ThisWorkbook.Sheets(1).Cells(1,1).value 'here you reference to correct Workbook, Worksheet and cell
oHtmlDoc.GetElementById(miCellVal)

1- And the straightforward way

oHtmlDoc.GetElementById(ThisWorkbook.Sheets(1).Cells(1,1).value)
BrunoQuintero
  • 151
  • 1
  • 4