VBA control button to navigate multipage according to one of the parameters entered in the text box.

Jyyyyyyyy

New Member
Joined
Jun 8, 2023
Messages
1
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Hi all,

I'm developing a form with multipages. I have designed it to be General info - Site 1 - Site 2 - Site 3 -.....

There's a textbox that need input from the users, regarding the Site where the material is produced. Different site has different info and setup.

Instead of navigating by clicking on the tab itself, the users would like to navigate by clicking the "Next" button, and the page will navigate according to the value of textbox "Site".

I've tried to use If-Else with GoTo, the results isnt going well.

May I have your help or suggestion to implement this?
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
Maybe something like this:
VBA Code:
Private Sub CommandButton1_Click()
    Dim i As Long
    For i = 0 To Me.MultiPage1.Pages.Count - 1
        If Me.MultiPage1.Pages(i).Caption = Me.TextBox1.Value Then
            Me.MultiPage1.Value = i
        End If
    Next
End Sub
Replace the Button, MultiPage and Textbox names accordingly.
 
Upvote 0
Hi welcome to forum

see if this code will do what you want

VBA Code:
Private Sub CommandButton1_Click()
    Dim LastPage As Long, Index As Long
    Index = Val(Me.TextBox1.Value) - 1
    With Me.MultiPage1
        LastPage = .Pages.Count - 1
        .Value = IIf(Index > LastPage, LastPage, IIf(Index < 0, 0, Index))
    End With
End Sub

I have assumed users will just enter a numeric value from 1 to last page number to select required Page?

Change control names as required

Dave
 
Upvote 0

Forum statistics

Threads
1,224,812
Messages
6,181,088
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