Avatar of mldaigle1
mldaigle1
Flag for Canada asked on

Macro Excel - Activex Button that goes on a hidden sheet

Hello,

I have hidden all the sheets in a workbook except Sheet1, on which I have multiple Activex buttons.  

When I click on Button1, it goes on the sheet2 and on sheet2 i have a "back" button that once i click on it, will bring me back to sheet1
I have 10 buttons like this.

Since I have hide all the sheets except Sheet1, i really don't know how I can activate a sheet,  It does give me an error message.

Any suggestion how I can resolve that issue (work with hidden sheets but been able to access it when i press an activex button)

Thanks in advance,

/mld
Microsoft Excel

Avatar of undefined
Last Comment
mldaigle1

8/22/2022 - Mon
byundt

Are you saying that you want to activate a hidden worksheet? If so, you must first make it visible, then you can activate it. The following sub will make a hidden worksheet visible and activate it. If run again, it will make the worksheet hidden. If you used a Forms control command button (instead of ActiveX), you could write one sub like this one, and call it from buttons on both the Master worksheet and the one being hidden/unhidden.
Sub ToggleSheetVisibility()
Dim ws As Worksheet
With Worksheets("Sheet2")
    If .Visible = xlSheetVisible Then
        .Visible = xlSheetVeryHidden
    Else
        .Visible = xlSheetVisible
        .Activate
    End If
End With
End Sub

Open in new window


If your problem is that you are using recorded macros and they are activating worksheets and selecting cells, then the better solution may be to rewrite the macro so you don't need to activate or select anything. You can then keep hidden worksheets hidden, yet still let your macro run.
ASKER CERTIFIED SOLUTION
byundt

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
mldaigle1

ASKER
Hello byundt,

Your solution is just perfect for what i need.  

You make my day,

xxx

/mld
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy