leeksleeks
Board Regular
- Joined
- Oct 31, 2013
- Messages
- 96
Hi,
I am trying to write an ErrHandler code but am having a few issues. Basically I want the Err message to delete a worksheet called "Scorecard" and one called "Comparison" if they exist. If they don't then I would like the macro to continue. The macro I have written scrapes a website and takes the id from the web address eg www.website/101. It is controlled by a popup box thats asks for a start number (101) and an end number (105). The website however sometimes has gaps between the numbers so a logical sequence of 101 - 105 may be missing number 103 which is why I have the ErrHandler to skip the macro. I would then like the macro to continue with the next webpage (104) after the Errhandler has dealt with the webpage that doesn't exist
Here is what I have so far:
ErrHandler:
Application.DisplayAlerts = False
Sheets("Scorecard").Delete
Sheets("Comparison").Delete
Application.DisplayAlerts = True
The problem I have is that I get a "Run-time error '9': Subscript out of range" when the website I am scraping data off doesn't exist. I have tried adding On Error resume Next and On Error GoTo 0 messages before the code but that hasn't worked.
Any help you can provide will be greatly appreciated.
I am trying to write an ErrHandler code but am having a few issues. Basically I want the Err message to delete a worksheet called "Scorecard" and one called "Comparison" if they exist. If they don't then I would like the macro to continue. The macro I have written scrapes a website and takes the id from the web address eg www.website/101. It is controlled by a popup box thats asks for a start number (101) and an end number (105). The website however sometimes has gaps between the numbers so a logical sequence of 101 - 105 may be missing number 103 which is why I have the ErrHandler to skip the macro. I would then like the macro to continue with the next webpage (104) after the Errhandler has dealt with the webpage that doesn't exist
Here is what I have so far:
ErrHandler:
Application.DisplayAlerts = False
Sheets("Scorecard").Delete
Sheets("Comparison").Delete
Application.DisplayAlerts = True
The problem I have is that I get a "Run-time error '9': Subscript out of range" when the website I am scraping data off doesn't exist. I have tried adding On Error resume Next and On Error GoTo 0 messages before the code but that hasn't worked.
Any help you can provide will be greatly appreciated.