Quickly Disable All NONE Active Tabs On A Multipage

Sharid

Well-known Member
Joined
Apr 22, 2007
Messages
1,029
Office Version
  1. 2016
Platform
  1. Windows
Hi

Is there a way to quickly disable all NONE active tabs on a multipage, with out having to reference each page?

Example
I have Multipage1 which will not have its tabs visible and pages will change via buttons. On each page of MultiPage1 I will have Multipage2 this will also have several pages. A bit like the image below. All pages must be enabled at the start.

1588336711200.png

On EACH PAGE of Multipage2 there will be buttons TO RUN THE CODE.

What I am after is that when the buttons is clicked and code runs, it will disable all other pages in this case it will be Page5 and 6. When the code ends it will enable the disabled pages. Some thing like this Mr Excel Links which was for a tab strip.

VBA Code:
Private Sub CommandButton1_Click ()

' Command Button 1 is on Page 4, On click All NONE active pages on MultiPage2 are disabled.
'My Code runs
'My Code Ends and then
'Code to enable all disabled pages on multipage 2

End Sub
 

Some videos you may like

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.

mikerickson

MrExcel MVP
Joined
Jan 15, 2007
Messages
23,904
Its not clear to me which pages of the multipage you want to disable, but code like

VBA Code:
Multipage1.Pages(3).Enabled=False
' some code
Multipage1.Pages(3).Enabled=True

will disable and re-enable a particular page.

and code like

VBA Code:
MultiPage1.Enabled = False
' some code
MultiPage1.Enabled = True
will prevent the user from selecting a different page of the multipage.
 

Sharid

Well-known Member
Joined
Apr 22, 2007
Messages
1,029
Office Version
  1. 2016
Platform
  1. Windows
Hi mikerickson

Thanks for your reply. I was looking at an easier way to disable and enable them rather than reference each Page to be enabled and disabled as there are several Pages on a multipage and several multipages, each with several pages. I was hoping that there might be a quick fix, one code to rule them all.

e.g, when the code is run the active page remains true all others change to false and at the end of the code all false pages are enabled. WITHOUT having to reference each page.

I attached a link in my first post, I think that does it for tabs strips but was not sure for multipage pages. Could someone with a bit more vba experience have a look at that link in my above post and advise.
 

mikerickson

MrExcel MVP
Joined
Jan 15, 2007
Messages
23,904
Since its in the middle of a sub, you could just disable the whole MultiPage. or You could write a sub that will do it for all the pages in a MultiPage

Put this in the userform's code module and use it as indicated

VBA Code:
Sub mySub
    InActivePagesEnabled(MultiPage1) = False
    ' more code
    InActivePagesEnabled(MultiPage1) = True
End Sub

Property Get InActivePagesEnabled(aMultiPage As MSForms.MultiPage) As Boolean
    Dim onePage As MSForms.Page
    InActivePagesEnabled = True
    For Each onePage In aMultiPage.Pages
        InActivePagesEnabled = InActivePagesEnabled And (onePage.Enabled)
    Next onePage
End Property

Property Let InActivePagesEnabled(aMultiPage As MSForms.MultiPage, inVal As Boolean)
    Dim onePage As MSForms.Page
    For Each onePage In aMultiPage.Pages
        If onePage.Index <> aMultiPage.Value Then
            onePage.Enabled = inVal
        End If
    Next onePage
End Property
 

Sharid

Well-known Member
Joined
Apr 22, 2007
Messages
1,029
Office Version
  1. 2016
Platform
  1. Windows
mickrickson

Super just what I was after.
 

Watch MrExcel Video

Forum statistics

Threads
1,122,473
Messages
5,596,356
Members
414,061
Latest member
JJSB

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