Run-Time Error 157121 - Application-defined or object-defined error

Elmer_J_Fudd

New Member
Joined
Dec 16, 2014
Messages
3
Can someone help me understand why?

Problem

This code does not work

Sub Cover()
'
ActiveWindow.ScrollWorkbookTabs Sheets:=12
Sheets("(3) Cover Sheet").Select
Range("F41").Select
End Sub

This Code does work

Sub GoTo_Tab_11()


ActiveWindow.ScrollWorkbookTabs Sheets:=12
Sheets("(11) Summary").Select
ActiveWindow.SmallScroll Down:=-135
End Sub
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
In the active workbook, is there a sheet named exactly "(3) Cover Sheet"?

Double-Check the spelling on the tab. Also check if the sheet name has a trailing space e.g.;
"(3) Cover Sheet "


On another note, sheets can also be selected by their position. This selects the 3rd sheet regardless of its name
Sheets(3).Select
 
Upvote 0
Thank you for your willingness to help me.

I check to spelling and made sure there are no leading or trailing spaces. - Same

I saved the file in three different versions to see if that might have an effect - Same result

I re did the macro

Code:
Sub Cover_3()
' Cover_3 Macro
    ActiveWindow.ScrollWorkbookTabs Sheets:=-12
[I][COLOR=#ff0000]    Sheets(3).Select[/COLOR][/I]
End Sub
[CODE] - Same result

I just don't understand why the same code (with the exception of the sheet name) will work on the other macros but not this one.

Thanks again for your help

EJF
 
Upvote 0
Maybe the real Sheet(3) is hidden and you think "(3) Cover Sheet" is Sheet(3)

Try this...

Code:
[COLOR=darkblue]Sub[/COLOR] Cover_3()
[COLOR=green]' Cover_3 Macro[/COLOR]
ActiveWindow.ScrollWorkbookTabs Sheets:=-12
[B]Sheets(3).Visible = [COLOR=darkblue]True[/COLOR][/B]
Sheets(3).Select
[COLOR=darkblue]End[/COLOR] [COLOR=darkblue]Sub[/COLOR]


That doesn't explain why you cannot select "(3) Cover Sheet" by name though if it's visible.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,216,445
Messages
6,130,685
Members
449,585
Latest member
Nattarinee

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