Command Buttons on Userform

PaulWJ

New Member
Joined
Dec 4, 2023
Messages
12
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
I have a multipage Userform which has 9 tabs at the top. The tabs are selected based on a number of options (they prompt a user to ask specific questions based on different scenarios). Essentially, however, they all do the same thing - check the questions have been answered correctly.

I can add Command Buttons on each (Confirm, Cancel, Clear & Other), but each needs it's own private sub, which runs on the 'click' of each button. I've done one tab, but is here any way to replicate the code on the buttons on the other tabs (rather than having the same four bits of code replicated 9 times?
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
Is it basically the same code (or logic) for every page?
 
Upvote 0
Yes Rory, it is.

JK - honestly, because I didn't know I could do that :) First stab at a multipage userform and still finding my way round. I'll give that a go.
 
Upvote 0
Paul: You can use the Value property of the multipage to get the page number (zero indexed) and have the buttons act accordingly..
 
Upvote 0
Thanks both. I will have a play and see what I can do. If I need more help, I'll be back.
 
Upvote 0

Forum statistics

Threads
1,223,888
Messages
6,175,219
Members
452,619
Latest member
Shiv1198

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