Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

"On error....go to" staement is not working in my macro 2

Status
Not open for further replies.

misho00

Technical User
Dec 23, 2002
3
EG
*My macro is opening certain number of files according to user input to take some data and put them in a table.

*I include "On error .... go to" statement in my macro to bypass the loop when some files are missed

*The macro runs correctly when facing the first error it proberly bypass the missed file, but it hangs when facing the second error...

pls help, i rreally need this in my work..
 
I assume that you have a RESUME NEXT at the end of your exception handling routine?
 
You may want to post a snipit of your code for us to look at.
 
Pls explaine where to put resume next in the macro, what i know that "resume next" is another kind of fo error...
Anyway here is the macro itself, as I said it opens files in a range that defined by user... thx 4 helping


Sub mmm()
Application.ScreenUpdating = False
Dim date1 As Date
Dim date2 As Date

Range("D3").Select
date1 = Selection.Value
Range("E3").Select
date2 = Selection.Value
directory = "\\Agiba2\opr\Production\Fields\As"
g = 0
For i = date1 To date2
mon = Format(i, "mmm")
mo = Format(i, "mm")
da = Format(i, "dd")
yr = Format(i, "yy")
yea = Format(i, "yyyy")
directory = "\\Agiba2\opr\Production\Fields\As\" & yea & "\" & mon & "-" & yea & "\"
file = "AS" & "-" & da & "-" & mo & "-" & yr & ".xls"
On Error GoTo err
Workbooks.Open FileName:=directory & file
Windows(file).Activate
Sheets("DAILY REPORT").Select
Range("G61").Select
Selection.Copy
Windows("macro.xls").Activate
Sheets("Sheet1").Select
Range("A6").Offset(g, 0).Select
Selection.Value = i
ActiveCell.Offset(0, 1).Select
Selection.PasteSpecial Paste:=xlValues
g = g + 1
Windows(file).Activate
ActiveWorkbook.Close (False)
err:
Next i
Range("d3").Select
Application.ScreenUpdating = True
End Sub
 
thanks for all of u the macro now is working properly by putting reume next after err:. Also i changed the
ActiveWorkbook.Close (False) to
workbooks (file).colse (false)

thx again
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top