2016-08-19 93 views
0

我想用visual basic在excel中执行几行数据搜索。试图从Visual Basic中循环搜索

基本上,搜索每个产品的网站...并不重要,如果它打开多个窗口或选项卡或任何...没有什么需要与网页做。这是我当前的尝试:

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"

请帮助我,可能很简单,但我是新来的。

回答

0

而实现这样的:

While {test} 
    {actions} 
Wend 

或更典型:

Do While {test} 
    {actions} 
Loop 
+0

谢谢你添。我想我提前问了一下,而不是做了这样的事情: 直到IsEmpty(....) 循环 谢谢! – user1825494