1
當使用宏搜索時,我無法搜索我知道在Excel表單中存在的單詞。我檢查了所有選項,但無法找到爲什麼會發生這種情況。 var2是1082591.html和1082592.html等等。當我在excel中找到Total時,它找不到它。由於通過宏搜索單詞時查找函數不起作用
Sub DataPull()
Dim Website
Application.DisplayAlerts = False
var1 = 2
Do Until Range("A" & var1) = ""
var2 = Range("A" & var1).Value
Hostteam = Range("C" & var1).Value
Hosts = Hostteam & " innings"
Visitorteam = Range("D" & var1).Value
Visitors = Visitorteam & " innings"
Website = "http://www.espncricinfo.com/indian-premier-league-2017/engine/match/" & var2
Set myIE = CreateObject("InternetExplorer.Application")
myIE.Navigate Website
myIE.Visible = True
Application.Wait Now + TimeSerial(0, 0, 5)
SendKeys "^a"
Application.Wait Now + TimeSerial(0, 0, 1)
SendKeys "^c"
Application.Wait Now + TimeSerial(0, 0, 1)
Workbooks.Add
ActiveWorkbook.SaveAs Filename:=var2
ActiveSheet.Paste
Application.Wait Now + TimeSerial(0, 0, 10)
Cells.Find(What:=Hosts, After:=ActiveCell, LookIn:= _
xlValues, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:= _
xlNext, MatchCase:=False, SearchFormat:=False).Activate
Cells.Find(What:="Total", After:=ActiveCell, LookIn:= _
xlValues, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:= _
xlNext, MatchCase:=False, SearchFormat:=False).Activate
ActiveCell.Offset(0, 2).Copy
ThisWorkbook.Activate
Range("J" & var1).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Workbooks(var2).Activate
Cells.Find(What:=Visitors, After:=ActiveCell, LookIn:= _
xlValues, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:= _
xlNext, MatchCase:=False, SearchFormat:=False).Activate
Cells.Find(What:="Total", After:=ActiveCell, LookIn:= _
xlValues, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:= _
xlNext, MatchCase:=False, SearchFormat:=False).Activate
ActiveCell.Offset(0, 2).Copy
ThisWorkbook.Activate
Range("L" & var1).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
myIE.Quit
Set myIE = Nothing
Err.Clear
Workbooks(var2).Activate
ActiveWorkbook.Close
ThisWorkbook.Activate
Range("O" & var1).Value = "Done"
var1 = var1 + 1
Loop
End Sub
我們將無法確定您的代碼無法正常工作的原因,除非您將問題粘貼到無法使用的代碼中。 – YowE3K