On error goto label error

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
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
"Workbooks(WRKBK1).Sheets(CurrentTab).Cells.Select"

Cells can only be selected on the active sheet (your code is not activating each sheet).
 
Upvote 0

Forum statistics

Threads
1,224,603
Messages
6,179,849
Members
452,948
Latest member
UsmanAli786

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top