Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I've having some trouble understanding how to do this Error Handling thing.
Any assistance that's offered is greatly appreciated! My coding is at the end. The macro is opening a series of files, manipulating them, then resaving them with a new name. The file names and manipulations are all listed in a spreadsheet; the macro pulls one row of information, does its thing, then moves on to the next row until it reaches its stop command. Where I'm having trouble with the error handling is getting the macro to continue on its way after an error (if I understand correctly what's going on, it actually is continuing on its way, but then stops upon reaching a second row with an error) My goal is to have any errors put a message in a cell of the offending row, rather than a pop-up message. There's actually a couple loops in the macro, my thought is that I can put in several "on error goto" err_handler1, err_handler2, etc., and have each err_handler populate a different message. Depending on the step where the error occurs, I can then populate that cell with a message that instructs the user what correction is necessary. So here's the coding I was using on the first loop. Thanks in advance for any help! Do Until Grow = NextRow Windows("Personal.xls").Activate Sheets("Info Delivery").Activate If IsEmpty(Cells(Grow, 28)) = True Then GFolder = Cells(Grow, 27) Else GFolder = Cells(Grow, 27) & "\" & Cells(Grow, 28) ChDir SourcePath & GFolder If Cells(Grow, 41) = "Y" Then Application.EnableEvents = False On Error GoTo Err_Hdler1 Workbooks.Open Filename:=SourcePath & GFolder & "\" & Cells(Grow, 33) Application.EnableEvents = True End If Err_Hdler1: Select Case Err.Number Case Is = 1004 Range("F" & SummaryRow) = "File Not Found" Case Else Range("F" & SummaryRow) = "Unknown Error" End Select SummaryRow = SummaryRow + 1 Grow = Grow + 1 Loop |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Continue running macro until last line of data. | Excel Programming | |||
Error handling error # 1004 Run-time error | Excel Programming | |||
How to continue macro if there is an error value | Excel Programming | |||
Error Handling - On Error GoTo doesn't trap error successfully | Excel Programming | |||
Error handling with a handling routine | Excel Programming |