Hide all multipage

urobee

Board Regular
Joined
Jan 30, 2015
Messages
98
Hy, I want to hide all the multipages on a given part of the macro, so i can show later only the needed tab later.
I work with 8 tab currently but i never need to show them all on the same moment.

This is my code at this moment:

Code:
For i = 0 To 7
    MultiPage1.Pages(i).Visible = False
Next i

The problem:
This is really slow, i mean it is take a few second to do this in my UserForm.
The Userform has tons of textboxes and other controls.

My experience is when i hide the pages on two steps the code is running relatively faster.
So this is faster:
Code:
For i = 1 To 7
    MultiPage1.Pages(i).Visible = False
Next i

MultiPage1.Pages(0).Visible = False

than this:

Code:
For i = 0 To 7
    MultiPage1.Pages(i).Visible = False
Next i

Is there any other method to do this?
Thanks!
 
Last edited:

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
Try this:
Code:
Private Sub CommandButton2_Click()
'Modified  8/3/2018  9:23:02 PM  EDT
Dim i As Long
For i = 1 To 7
    MultiPage1.Pages(i - 1).Visible = False
Next i
End Sub
 
Upvote 0
Does this make any difference in speed ?

Code:
With MultiPage1
    .Visible = False
    For i = 1 To 7
        .Pages(i).Visible = False
    Next i
    .Visible = True
End With
 
Upvote 0
Hy, thanks for Your answer!
I've tried Your code but it works maybe with the same speed as my original code.
BTW Thanks again! :)
 
Upvote 0
Hy,
I've tried Your code too, but the result almost the same as with my second code where I hide the tabs in two steps.
Thanks for Your help!

I think it can't be more faster, because of the mass amount of the textboxes.
I've tried it on a normal PC and it is run much more faster... So i need to talk with the IT guys in my workplace to get a better PC :D :D
 
Upvote 0
Please define fast and slow.
Some people think 1.3 milliseconds is slow as some people think 1.3 milliseconds is fast.

I would surely think hiding 7 Multipage tabs would only take mere seconds.

I'm surprised it would depend on how many controls you have on the Tab
 
Last edited:
Upvote 0
I get a macro and measeure the running time of the macros:

#1 - 2,56sec
Code:
For i = 0 To 7
MultiPage1.Pages(i).Visible = False
Next i

#2 - 0,72 sec
Code:
For i = 1 To 7
MultiPage1.Pages(i).Visible = False
Next i
MultiPage1.Pages(0).Visible = False

#3 - 2,6 sec (this was Your code)
Code:
For i = 1 To 7
    MultiPage1.Pages(i - 1).Visible = False
Next i

#4 - 2,63sec (this was Jaafar Tribak's code but I modify it to start from the first tab. If I run it without hiding the first tab (the original code of Jaafar Tribak) the running time was only 0,37sec :O )
Code:
With MultiPage1
    .Visible = False
    For i = 0 To 7
        .Pages(i).Visible = False
    Next i
    .Visible = True
End With

I've tried to move all the controls from the multipage to an outer region of the userform but this was not affect the running time significantly.

This is my PC when I make the program, but the PC where it will be used is a really slooooow PC so these times will be much longer times :(
I will need to talk with the IT Guys :) :D
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,178
Members
453,021
Latest member
Justyna P

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