VBA runs from developer but wont run from icon

graudales

New Member
Joined
Nov 9, 2015
Messages
19
Hello Everybody and thank you for your help in advance, I love Mr. excel.
Well I have done way more complex codes than this one but i hit the wall. I recorded a macro that hides current sheet and goes to main menu sheet, it runs fine when i open and run it with the developer but when I click the icon just jumps from one sheet to anotherone withot hidint the sheet. Is making me crazy cause is fine but why ust the go to order works but not the part of hiddind the sheet?
here is the code; I am sure I am missing some kind of simple setting and I cannot comprehend what is it, I havent been working for over 5 years and I am rusted.. any comment would be very welcome.


Sub Macro2()

Sheets("Chewy Private Label").Select
Sheets("chewy Private Label").Visible = False
Sheets("Menu Home").Select
Range("A10").Select
End Sub
Sub Macro3()

Sheets("Menu Home").Select
Sheets("Chewy Private Label").Visible = True
Sheets("Chewy Private Label").Select
Range("A6").Select
End Sub
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.

Craig_Moore

New Member
Joined
Dec 12, 2018
Messages
23
I've never used shapes with macros my self and wasn't aware you could so you have taught me something.
the below is what i use on my sheets but if you don't want people to be able to right click and unhide the sheets manually i would use =xlSheetVeryHidden

Worksheets("Chewy Private Label").Visible = xlSheetVisible
Worksheets("Menu Home").Visible = xlSheetHidden

Worksheets("Menu Home").Visible = xlSheetVisible
Worksheets("Chewy Private Label").Visible = xlSheetHidden
 

yky

Well-known Member
Joined
Jun 7, 2011
Messages
1,874
Office Version
  1. 2010
Platform
  1. Windows
Works on mine. I inserted two shapes, a rectangle and a circle, and assigned a macro to each. Since I don't have sheet names like yours, I just use index number. The macro hid and unhid sheets. I didn't check range.select behavior.

VBA Code:
Sub Macro2()

Sheets(3).Select
Sheets(3).Visible = False
Sheets(1).Select
Range("A10").Select
End Sub
Sub Macro3()

Sheets(1).Select
Sheets(3).Visible = True
Sheets(3).Select
Range("A6").Select
End Sub
 

Forum statistics

Threads
1,136,909
Messages
5,678,522
Members
419,769
Latest member
Sparks66

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
Top