HeltonHouse
New Member
- Joined
- May 12, 2011
- Messages
- 1
I have searched the web all day and have not found an answer. I have two workbooks. One is created at the begining of the year and the other is used to update it each month. I have a loop statement that has an on error goto label. The first two tabs in my main workbook are not in the new workbook. the error works for the first sheet but on the next sheet I get an error meassage. here is the current code:
Sub CopyTabData()
Dim i As Double
Dim CurrentTab, WRKBK1, WRKBK2 As String
WRKBK1 = ActiveWorkbook.Name
WRKBK2 = "Post Reset Tracking - Download.xlsb"
Application.DisplayAlerts = True
For i = r To Workbooks(WRKBK1).Sheets.Count
On Error GoTo SKSTP
CurrentTab = Workbooks(WRKBK1).Sheets(i).Name
Workbooks(WRKBK2).Sheets(CurrentTab).Cells.Copy
Workbooks(WRKBK1).Sheets(CurrentTab).Cells.Select
ActiveSheet.Paste
SKSTP:
Next
Application.DisplayAlerts = True
End Sub
Sub CopyTabData()
Dim i As Double
Dim CurrentTab, WRKBK1, WRKBK2 As String
WRKBK1 = ActiveWorkbook.Name
WRKBK2 = "Post Reset Tracking - Download.xlsb"
Application.DisplayAlerts = True
For i = r To Workbooks(WRKBK1).Sheets.Count
On Error GoTo SKSTP
CurrentTab = Workbooks(WRKBK1).Sheets(i).Name
Workbooks(WRKBK2).Sheets(CurrentTab).Cells.Copy
Workbooks(WRKBK1).Sheets(CurrentTab).Cells.Select
ActiveSheet.Paste
SKSTP:
Next
Application.DisplayAlerts = True
End Sub