我正在尝试使用Visual Basic在excel中搜索几行数据。
基本上,在网站上搜索每种产品...打开多个窗口或标签页或其他内容都没关系...网页也不需要做任何事情。这是我目前的尝试:
Private Sub CommandButton1_Click()
Dim index As Integer
index = 1
Dim searchme As String
While Worksheets("Sheet1").Cells(index, 1).Value <> Null
searchme = worsheets("Sheet1").Cells(index, 1).Value
searchmelink = "https://www.grainger.com/search?" & _
"searchBar=true&searchQuery=" & searchme
ThisWorkbook.FollowHyperlink Address:=searchmelink, NewWindow:=True
index = index + 1
End While
End Sub
由于某种原因,我在
End While
上遇到错误。"Compile error:
Expected: If or Select or Sub or Function or Property or Type or With or Enum or end of statement"
请帮我,可能很简单,但是我是新手。
最佳答案
虽然是这样实现的:
While {test}
{actions}
Wend
或更典型地:
Do While {test}
{actions}
Loop
关于vba - 尝试从Visual Basic循环搜索,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39047410/