Thread: on error
View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
alf bryn alf bryn is offline
external usenet poster
 
Posts: 31
Default on error

I had the same problem but R B Smissaert solved my problem. Perhaps you
could use his solution?

Link: http://www.excelforum.com/showthread.php?t=550766


"Linus" <u23074@uwe wrote in message news:61d412e214333@uwe...
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
error code will work for the first file but shows me the error on any
subsequent issue.

thanks

On Error GoTo error

Range("b2").Select
For Each rw In Range("block1")
ChDir rw.Offset(0, 1)
x = rw
If rw = 0 Then GoTo endmacro
Set wkb = Workbooks.Open(rw, Notify:=False)
Application.Goto Reference:="interestinput"
Selection.Copy
Windows("US Bank Statement Interest multiple months.xls").Activate
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
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

error:
Next rw
endmacro:
Application.DisplayAlerts = True
Application.ScreenUpdating = True
Range("a2").Select
End Sub