fredrerik84
Active Member
- Joined
- Feb 26, 2017
- Messages
- 383
Hi Im working on pulling some information from a web page , unfortunately it was not so straightforward as it usually is. But I found a solution to get it to be correctly displayed in excel. here is my working code.
Ive tested this manually for every "HTMLrows" by changing variable i from 0 - 50 then run the code and everything works perfect on everyrow. However trying to make a master loop for the i var was harder that i thought.
does anyone know how to make this 2nd master loop to loop trough all the html rows ?
Code:
i = 3
On Error Resume Next
str = HTMLRows(i).innerText
If InStr(str, "eller") = 0 Then
For x = 2 To 200
If Trim(Split(HTMLRows(i).innerText, vbCrLf)(x)) <> "" Then
str = Trim(Split(HTMLRows(i).innerText, vbCrLf)(x))
If InStr(str, "+") = 0 Then
If s = 1 Then
yy = 7
ElseIf s = 2 Then
yy = 1
ElseIf s = 3 Then
yy = 6
ElseIf s = 4 Then
yy = 0
ElseIf s = 5 Then
yy = 5
ElseIf s = 6 Then
yy = -1
End If
Cells(j, y + yy).value = str
y = y + 1
s = s + 1
If s = 7 Then
s = 0
yy = 0
End If
If y = 9 Then
j = j + 1
y = 2
End If
End If
End If
Next x
Else
For x = 2 To 14
If Trim(Split(HTMLRows(i).innerText, vbCrLf)(x)) <> "" Then
str = Trim(Split(HTMLRows(i).innerText, vbCrLf)(x))
If InStr(str, "+") = 0 Then
If s = 1 Then
yy = 7
ElseIf s = 2 Then
yy = 1
ElseIf s = 3 Then
yy = 6
ElseIf s = 4 Then
yy = 0
ElseIf s = 5 Then
yy = 5
ElseIf s = 6 Then
yy = -1
End If
Cells(j, y + yy).value = str
y = y + 1
s = s + 1
If s = 7 Then
s = 0
yy = 0
End If
If y = 9 Then
j = j + 1
y = 2
End If
End If
End If
Next x
End If
Ive tested this manually for every "HTMLrows" by changing variable i from 0 - 50 then run the code and everything works perfect on everyrow. However trying to make a master loop for the i var was harder that i thought.
does anyone know how to make this 2nd master loop to loop trough all the html rows ?