我有一段代码从HTML应用程序中提取客户交易数据,将其添加到一起并将数字导入电子表格。代码循环显示工作表上的客户帐号列表,但我对导入电子表格的数据有疑问。它不是导入数据然后循环到下一个帐户,而是循环显示每个帐户并导入所有帐户的总数,而不是每个帐户的总数。希望这是有道理的,下面是我认为导致问题的代码部分,我不确定是否需要使用循环调整某些内容,或者它是否是"。值& #34;导致问题的原因。我将不胜感激任何建议/帮助。
Dim lastRow As Integer
lastRow = Cells(10000, 6).End(xlUp).Row
rowData = 6 'set it to the first row of player account data
dblTotalSlot = 0
dblTotalTable = 0
For x = rowData To lastRow
' Navigate to Search screen
IE.navigate my_url2
If Not IEWait(IE) Then
GoTo EndMe
End If
'check to see if user was successfully logged in
If Not IE.LocationURL Like "*search*" Then 'couldn't find the word 'Search' in the url, so it didn't make it here for some reason
MsgBox "Please check your username/password is correct and try again.", vbCritical, "Error"
GoTo EndMe
End If
IE.document.getElementById("accountNumber").Value = Me.Cells(x, 6).Value 'use the rowdata variable to get which row we are at
IE.document.getElementById("action").Click
If Not IEWait(IE) Then
GoTo EndMe
End If
IE.navigate my_url3
If Not IEWait(IE) Then
GoTo EndMe
End If
IE.document.getElementById("site").Value = Me.Cells(7, 4).Value
IE.document.getElementById("action").Click
If Not IEWait(IE) Then
GoTo EndMe
End If
dblCustomerTTotal = 0
dblCustomerSTotal = 0
For i = 1 To 1
Set TDelements = IE.document.getElementsByTagName("tr")
For Each TDelement In TDelements
If TDelement.className = "searchActivityResultsCustomerTContent" Then
dblCustomerTTotal = dblCustomerTTotal + VBA.CDbl(TDelement.ChildNodes(8).innerText)
ElseIf TDelement.className = "searchActivityResultsCustomerSContent" Then
dblCustomerSTotal = dblCustomerSTotal + VBA.CDbl(TDelement.ChildNodes(8).innerText)
End If
Next
Set elems = IE.document.getElementsByTagName("input")
For Each e In elems
If e.Value = "Next Results" Then
e.Click
If Not IEWait(IE) Then
GoTo EndMe
End If
i = 0
Exit For
End If
Next e
Next i
Me.Cells(rowData, 7).Value = dblCustomerTTotal
Me.Cells(rowData, 8).Value = dblCustomerSTotal
Me.Cells(rowData, 9).Value = dblCustopmerTTotal + dblCustomerSTotal
dblTotalT = dblTotalT + dblCustomerTTotal
dblTotalS = dblTotalS + dblCustomerSTotal
Next x
EndMe:
IE.Quit
Application.ScreenUpdating = True
On Error GoTo 0 'reset the error handler
End Sub