Excel vba error message "Run Time error 1004: Select Method of Worksheet class failed"

EverClear

New Member
Joined
Oct 23, 2012
Messages
32
Hi there,

I have been successfully executing the same code for quite a while, but when I attempted to run my macro this time I received a "Run Time error 1004: Select Method of Worksheet class failed" error message, and the macro bombs...

What the macro is supposed to do is perform the same sequence of steps, starting on the 4th worksheet in the file, and loop through the steps to the last worksheet in the file.

This is the code that I have been using:

For i = 4 To Sheets.Count
Sheets(i).Select

' various steps...

Next

This code has not produced any error messages -- until now.

Any ideas of how I could change this code would be appreciated. Thank you!!
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
Hi there,

I have been successfully executing the same code for quite a while, but when I attempted to run my macro this time I received a "Run Time error 1004: Select Method of Worksheet class failed" error message, and the macro bombs...

What the macro is supposed to do is perform the same sequence of steps, starting on the 4th worksheet in the file, and loop through the steps to the last worksheet in the file.

This is the code that I have been using:

For i = 4 To Sheets.Count
Sheets(i).Select

' various steps...

Next

This code has not produced any error messages -- until now.

Any ideas of how I could change this code would be appreciated. Thank you!!

Assuming you have at least 4 sheets in your workbook and that the error is in this line:
Sheets(i).Select
a guess would be that the sheet is hidden.
 
Upvote 0

Forum statistics

Threads
1,223,164
Messages
6,170,444
Members
452,326
Latest member
johnshaji

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