I am not sure why the On Error goto
does not handle the following error.
T10
that I select and change the URL and attempt to pull a table into the sheet.
I do this 20-30 times with different URL's.
Sometimes the data pull takes too long or something else happens that won't allow excel to get the data...
In those cases I want to handle the error and continue.
But I am still getting the runtime error '1004' and debug shows .Refresh BackgroundQuery:=False
highlighted.
But shouldn't the On Error grab 开发者_如何学Pythonthat and goto line CardDataPullError
further down in the sheet?
On Error GoTo CardDataPullError
NodeIP = "192.168.210.4"
Range("T10").Select
With Selection.QueryTable
.Connection = "URL;http://" & NodeIP & ":21495/" & Card & "/ispCktDBPage"
.WebSelectionType = xlSpecifiedTables
.WebFormatting = xlWebFormattingNone
.WebTables = "3"
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
On Error GoTo 0
'below is another section of code that highlights the cell red
'showing it had a problem pulling the data
GoTo SkipCard ' To skip error handler
CardDataPullError:
X = X
Cells(CardRow, CardCol).Interior.ColorIndex = 3 ' Red
SkipCard:
'other reasons to skip to
You forgot to put resume
in the CardDataPullError
error handler.
Therefore the error is not handled.
Change the code as follows:
CardDataPullError:
X = X
Cells(CardRow, CardCol).Interior.ColorIndex = 3 ' Red
Resume SkipCard:
精彩评论