Home |
Search |
Today's Posts |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
everything works great except when the file does not exist the macro still
does the Windows(x) activate, range("b6").copy when in fact Windows(x) does not exist. It copies range("b6") from my host workbook thanks Jim Thomlinson wrote: Once you have entered an error ahndler, you are in it until you "Resume" your normal execution with the "Resume" key word. Your code never resumes normal exectution. This means that after the first error you are now in an error handler for the remainder of the exectution. Once in an error handler any new errors will be unhandled and just pop up on you... From reading your code it looks like you are opening workbooks (directory in one column file name in the next) and copying data to your host workbook (let me know if I am off the mark here). If so then try this code... For Each rw In Range("block1") x = rw If rw = 0 Then GoTo endmacro on error resume next Set wkb = Workbooks.Open(rw.Offset(0, 1).value & "\" & _ rw.value, Notify:=False) if not wbk is nothing then Application.Goto Reference:="interestinput" Selection.Copy Windows("US Bank Statement Interest multiple months.xls").Activate Selection.PasteSpecial Paste:=xlPasteValues Windows(x).Activate Range("b6").Copy Windows("US Bank Statement Interest multiple months.xls").Activate Range("e2").End(xlDown).Offset(0, 2).Select Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False Selection.End(xlUp).Select Selection.Offset(1, 0).Select Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False Range(Selection, Selection.End(xlDown)).Select Selection.FillDown Range("b2").End(xlDown).Offset(1, 0).Select Application.CutCopyMode = False wkb.Close savechanges:=False end if Next rw endmacro: Application.DisplayAlerts = True Application.ScreenUpdating = True Range("a2").Select End Sub I'm using the following code to open up serveral files and grab information to post to a worksheet. If the file does not exist in the directory, my on [quoted text clipped - 42 lines] Range("a2").Select End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Counting instances of found text (Excel error? Or user error?) | Excel Worksheet Functions | |||
Error Handling - On Error GoTo doesn't trap error successfully | Excel Programming | |||
Form Err.Raise error not trapped by entry procedure error handler | Excel Programming | |||
Automation Error, Unknown Error. Error value - 440 | Excel Programming |