Multi paged vba form question

skinfreak

Board Regular
Joined
May 23, 2003
Messages
152
Hiya,

I am building a multi page/tabbed form in Excel for data entry and am having a few problems with it.

1) What is the code for flicking between the pages? I want a next button that will go to page 3, and a Previous button that will go to Page 1.

2) How do I set the default Page 1 on form load?

3) How do I minimise the main Excel window and only show the form? I have a macro that loads a splash screen with several options, one of which is loading the form. I want to minumise the main Excel windows with this option.

Thanks!
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.

MichaelRo

Well-known Member
Joined
Jun 7, 2004
Messages
549
Here we go:
1) What is the code for flicking between the pages? I want a next button that will go to page 3, and a Previous button that will go to Page 1.
Put this code in a button:
Code:
Dim i As Long

i = MultiPage1.Pages.Count - 1

'If you are on the last Page select the first one
If MultiPage1.Value = i Then
    MultiPage1.Value = 0
'If you are on the any other page - select the next one
Else
    MultiPage1.Value = MultiPage1.Value + 1
End If
2) How do I set the default Page 1 on form load?
On the Userform Initialize use the following:
Code:
'Select the first Page
MultiPage1.Value = 0
3) How do I minimise the main Excel window and only show the form? I have a macro that loads a splash screen with several options, one of which is loading the form. I want to minumise the main Excel windows with this option.
To minimize the excel window you can use the following code:
Code:
'Minimize Excel Window
ActiveWindow.WindowState = xlMinimized
 

skinfreak

Board Regular
Joined
May 23, 2003
Messages
152
MichaelRo said:
Here we go:
1) What is the code for flicking between the pages? I want a next button that will go to page 3, and a Previous button that will go to Page 1.
Put this code in a button:
Code:
Dim i As Long

i = MultiPage1.Pages.Count - 1

'If you are on the last Page select the first one
If MultiPage1.Value = i Then
    MultiPage1.Value = 0
'If you are on the any other page - select the next one
Else
    MultiPage1.Value = MultiPage1.Value + 1
End If

It works fine for the next button, and if i substitute
Code:
MultiPage1.Value = MultiPage1.Value + 1
with
Code:
MultiPage1.Value = MultiPage1.Value - 1
then the previous button works, but I don't understand the code that returns the user to the first page if there is no next page.

Other than that - Thanks Very Much!
 

MichaelRo

Well-known Member
Joined
Jun 7, 2004
Messages
549
The MultiPages are indexed 0 onwards - 0 being the first page of a multipage

My code says that if the index of the current page = the total count of pages (-1 to account for the first page being a zero) then select the first page.

I worked to your specifications but if you want a previous button use the following code as you will cause an error just by changing the +1 to a -1.

Code:
'Previous
Dim i As Long

i = MultiPage1.Pages.Count - 1

'If you are on the first Page select the last one
If MultiPage1.Value = 0 Then
    MultiPage1.Value = i
'If you are on the any other page - select the previous one
Else
    MultiPage1.Value = MultiPage1.Value - 1
End If
 

skinfreak

Board Regular
Joined
May 23, 2003
Messages
152

ADVERTISEMENT

And how would I minimise ALL windows? (i.e. the other sheets that a user has open before running this program?)
 

MichaelRo

Well-known Member
Joined
Jun 7, 2004
Messages
549
To minimize all windows you could minimize excel itself:

Code:
Application.WindowState = xlMinimized
 

skinfreak

Board Regular
Joined
May 23, 2003
Messages
152
The problem with that is the splash screen doesn't automatically come up because the program is minimised - it just blinks on the program bar in a minimised state.

Is there a way of maximising the splash screen - auto filling and centering the content with a plain white background? If the user couldn't see excel lying underneath, it wouldn't really make any difference (visually).
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,163,806
Messages
5,833,778
Members
430,232
Latest member
Testsubject

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