Avatar of mldaigle1
mldaigle1Flag 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
Avatar of byundt
byundt
Flag of United States of America image

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
Avatar of byundt
byundt
Flag of United States of America image

Blurred text
THIS SOLUTION IS 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
Avatar of mldaigle1
mldaigle1
Flag of Canada image

ASKER

Hello byundt,

Your solution is just perfect for what i need.  

You make my day,

xxx

/mld
Microsoft Excel
Microsoft Excel

Microsoft Excel topics include formulas, formatting, VBA macros and user-defined functions, and everything else related to the spreadsheet user interface, including error messages.

144K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo