Excel 2002
Below is my code that will create a new tab for the current month for each workbook in a folder. Sometimes there will be a workbook in the middle of a folder that will generate an error so I would like to be able to correct the error in the code but then re-run the macro. So I need to either start from the beginning of the folder and have it ignore any workbook that contains a tab already called "Feb 10" or have it start from the place I left off. Any help would be great! Thanks!
Below is my code that will create a new tab for the current month for each workbook in a folder. Sometimes there will be a workbook in the middle of a folder that will generate an error so I would like to be able to correct the error in the code but then re-run the macro. So I need to either start from the beginning of the folder and have it ignore any workbook that contains a tab already called "Feb 10" or have it start from the place I left off. Any help would be great! Thanks!
Code:
Dim fName As String
Dim fOUT As String, ws As Worksheet
Application.ScreenUpdating = False
Application.DisplayAlerts = False
CurDir "C:\... Recs2010\"
fName = Dir("*.xls")
Do While Len(fName) > 0 'open each file and make sheet changes
Workbooks.Open (fName)
Sheets("Jan 10").Copy After:=Sheets(Sheets.Count)
ActiveSheet.Name = "Feb 10"
Sheets(Sheets.Count).Select
Cells.Find(what:="January", After:=ActiveCell, LookIn:=xlFormulas _
, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
'Selection.Copy
ActiveCell.FormulaR1C1 = "'February 2010"
ActiveWorkbook.Close True 'Close and save workbok
fName = Dir 'ready next filename
Loop
Application.ScreenUpdating = True
Application.DisplayAlerts = True
MsgBox ("Done")