refer to a previously clicked command button

ThomasOES

Board Regular
Joined
Aug 29, 2017
Messages
174
In a macro I want to use an if statement if a command button was used.
regsel is the name of a userform and reg1 is a command button that launches a macro.
however the macro I want to check the status of the command button is not directly launched by the command button, but a bit further into the workbook.
Any ideas?
something like
VBA Code:
If regsel.reg1 = True Then regdeg = 1
currently I get a false status although the reg1 command button was used

Tom
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
Would changing the Command Button to a Toggle Button be an easy fix. You could then monitor and manage it's state from other parts of code...
 
Upvote 0
I'm using a command button to select what type of equation to apply to data. I suppose I could use an option button to select the equation type then a command button to launch the macro. I'll try it. I'll also experiment with using the command button to put a value in a named range and referring to the named range. Specifically I'm selecting what degree polynomial most accurately fits data and another macro to chart the data. The chart macro needs to know what degree polynomial to chart. So you see I need the command button to lauch a macro but to also contain some info. I would like the a similar code to the true/false for an option button.
Heres my userform

userform.gif


clicking 1st, 2nd or 3rd starts the macro corresponding to the needed equation. I would like the degree to be applied to the chart macro which contains an if/or statement selecting which degree to chart.
I'm hoping to avoid putting separate chart macros into each equation macro. The chart macro is quite large.
 

Attachments

  • userform.gif
    userform.gif
    21.5 KB · Views: 3
Upvote 0

Forum statistics

Threads
1,214,649
Messages
6,120,732
Members
448,987
Latest member
marion_davis

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