kuhmuhkuh
08-10-2014, 03:48 PM
Hello,
im quite new to vba and i got a problem in a webscrapper im coding right now.
1) i got this main code which calls all needed functions :
Public Sub maincode()
Dim Playernumber As Integer
Application.ScreenUpdating = False
For Playernumber = 1 To 100
Call ImportWebpageOverall(Playernumber)
Call pulldataOverall
Call ImportWebpageStandardLeagues(Playernumber)
Call pulldataStandardLeague
Call ImportWebpageSpecialEvent(Playernumber)
Call pulldataSpecialEvent
Call ImportWebpageOfflineEvents(Playernumber)
Call pulldataOfflineEvent
Next Playernumber
Call Name(Playernumber)
Call Race(Playernumber)
Call Race2(Playernumber)
Application.ScreenUpdating = True
End Sub
and we got this for the sub pulldataoverall()
Public Sub pulldataOverall()
Dim lastrowsheetone As Integer
Dim findmatch As Variant
Dim findname As String
Dim findelo As Integer
lastrowsheetone = Sheets("Players").UsedRange.Rows.Count
findmatch = Application.Match("1v1 Record:", Sheets("Tabelle3").Range("A1:A200"), 0)
If VarType(findmatch) = vbError Then
Exit Sub
Else
Sheets("Players").Cells(lastrowsheetone + 1, 3) = Sheets("Tabelle3").Cells(findmatch + 1, 2)
Sheets("Players").Cells(lastrowsheetone + 1, 5) = Sheets("Tabelle3").Cells(findmatch + 2, 2)
Sheets("Players").Cells(lastrowsheetone + 1, 7) = Sheets("Tabelle3").Cells(findmatch + 3, 2)
Sheets("Players").Cells(lastrowsheetone + 1, 9) = Sheets("Tabelle3").Cells(findmatch + 4, 2)
Sheets("Players").Cells(lastrowsheetone + 1, 4) = Sheets("Tabelle3").Cells(findmatch + 1, 3)
Sheets("Players").Cells(lastrowsheetone + 1, 6) = Sheets("Tabelle3").Cells(findmatch + 2, 3)
Sheets("Players").Cells(lastrowsheetone + 1, 8) = Sheets("Tabelle3").Cells(findmatch + 3, 3)
Sheets("Players").Cells(lastrowsheetone + 1, 10) = Sheets("Tabelle3").Cells(findmatch + 4, 3)
findname = Application.Match("Record & Games", Sheets("Tabelle3").Range("A1:A200"), 0)
Sheets("Players").Cells(lastrowsheetone + 1, 1) = Sheets("Tabelle3").Cells(findname + 1, 1)
Sheets("Players").Cells(lastrowsheetone + 1, 2) = Sheets("Tabelle3").Cells(findname + 4, 1)
Sheets("Players").Cells(lastrowsheetone + 1, 36) = Sheets("Tabelle3").Cells(findname + 5, 1)
findelo = Application.Match("ELO Rank:", Sheets("Tabelle3").Range("A1:A200"), 0)
Sheets("Players").Cells(lastrowsheetone + 1, 35) = Sheets("Tabelle3").Cells(findelo + 0, 2)
End If
End Sub
written in this sub is : If VarType(findmatch) = vbError Then
Exit sub
What i want now is not to only exit this sub but also dont call the other functions.
Like if this whole code is running for playernumber 1 and an error occurs in the pulldataoverall sub i dont want the code to call the other subs .
I hope its understandable what my problem is.
im quite new to vba and i got a problem in a webscrapper im coding right now.
1) i got this main code which calls all needed functions :
Public Sub maincode()
Dim Playernumber As Integer
Application.ScreenUpdating = False
For Playernumber = 1 To 100
Call ImportWebpageOverall(Playernumber)
Call pulldataOverall
Call ImportWebpageStandardLeagues(Playernumber)
Call pulldataStandardLeague
Call ImportWebpageSpecialEvent(Playernumber)
Call pulldataSpecialEvent
Call ImportWebpageOfflineEvents(Playernumber)
Call pulldataOfflineEvent
Next Playernumber
Call Name(Playernumber)
Call Race(Playernumber)
Call Race2(Playernumber)
Application.ScreenUpdating = True
End Sub
and we got this for the sub pulldataoverall()
Public Sub pulldataOverall()
Dim lastrowsheetone As Integer
Dim findmatch As Variant
Dim findname As String
Dim findelo As Integer
lastrowsheetone = Sheets("Players").UsedRange.Rows.Count
findmatch = Application.Match("1v1 Record:", Sheets("Tabelle3").Range("A1:A200"), 0)
If VarType(findmatch) = vbError Then
Exit Sub
Else
Sheets("Players").Cells(lastrowsheetone + 1, 3) = Sheets("Tabelle3").Cells(findmatch + 1, 2)
Sheets("Players").Cells(lastrowsheetone + 1, 5) = Sheets("Tabelle3").Cells(findmatch + 2, 2)
Sheets("Players").Cells(lastrowsheetone + 1, 7) = Sheets("Tabelle3").Cells(findmatch + 3, 2)
Sheets("Players").Cells(lastrowsheetone + 1, 9) = Sheets("Tabelle3").Cells(findmatch + 4, 2)
Sheets("Players").Cells(lastrowsheetone + 1, 4) = Sheets("Tabelle3").Cells(findmatch + 1, 3)
Sheets("Players").Cells(lastrowsheetone + 1, 6) = Sheets("Tabelle3").Cells(findmatch + 2, 3)
Sheets("Players").Cells(lastrowsheetone + 1, 8) = Sheets("Tabelle3").Cells(findmatch + 3, 3)
Sheets("Players").Cells(lastrowsheetone + 1, 10) = Sheets("Tabelle3").Cells(findmatch + 4, 3)
findname = Application.Match("Record & Games", Sheets("Tabelle3").Range("A1:A200"), 0)
Sheets("Players").Cells(lastrowsheetone + 1, 1) = Sheets("Tabelle3").Cells(findname + 1, 1)
Sheets("Players").Cells(lastrowsheetone + 1, 2) = Sheets("Tabelle3").Cells(findname + 4, 1)
Sheets("Players").Cells(lastrowsheetone + 1, 36) = Sheets("Tabelle3").Cells(findname + 5, 1)
findelo = Application.Match("ELO Rank:", Sheets("Tabelle3").Range("A1:A200"), 0)
Sheets("Players").Cells(lastrowsheetone + 1, 35) = Sheets("Tabelle3").Cells(findelo + 0, 2)
End If
End Sub
written in this sub is : If VarType(findmatch) = vbError Then
Exit sub
What i want now is not to only exit this sub but also dont call the other functions.
Like if this whole code is running for playernumber 1 and an error occurs in the pulldataoverall sub i dont want the code to call the other subs .
I hope its understandable what my problem is.