refer to a previously clicked command button

ThomasOES

Board Regular
Joined
Aug 29, 2017
Messages
163
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

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes

igold

Well-known Member
Joined
Jul 8, 2014
Messages
2,695
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
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...
 

ThomasOES

Board Regular
Joined
Aug 29, 2017
Messages
163
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: 1

Forum statistics

Threads
1,144,391
Messages
5,724,075
Members
422,535
Latest member
navjeet

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