vba - 尝试从Visual Basic循环搜索

标签 vba excel while-loop compiler-errors basic

我正在尝试使用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/

相关文章:

vba - 如何循环访问多个网站的 "getElementById"VBA?

Excel函数将每第n行转置为列

java - Excel 中显示的 Apache POI : getting a number as a string,

excel - 如何引用表格列标题名称和表格行号?

c - While 循环内的优先级

excel - 如何将 IFERROR 应用于 Excel 中的所有单元格

vba - 如何使用索引号按指定顺序从范围中选择单个单元格?

excel - 自动工作表计算单元格值更改不起作用

c++ - 在 while 循环中使用输入重定向

java - 如何在唯一迭代中从循环中提取值?