简体   繁体   中英

Selecting drop box (VBA)

I can click drop box option with my code. But i want to click this based on value on excel sheets.

What should i do to do it? I made sheet1 and there is option 1 (text) in A2 cell.

Sub Dropdowncombobox()

Dim bot As New WebDriver


bot.Start "chrome"

bot.Get "https://the-internet.herokuapp.com/dropdown"

Stop

Dim ele As SelectElement
Set ele = bot.FindElementById("dropdown").AsSelect

ele.SelectByText "Option 1"

You can get the value of the cell and pass it further as follows:

ele.SelectByText Sheet1.Range("A2").Value

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM