Hi Wiggy
You say "UserForm" but also say you have assingned Macros to them which would suggest they are on a Worksheet. So I need to ask are the Controls on a UserForm ? If they are not and are on a Worksheet are they from the "Control toolbox" or "Forms" ?
Dave
If you only want the user to have one choice at the time, you should use OptionButtons. OzGrid Business Applications
If you only want the user to have one choice at the time, you should use OptionButtons.
Dave,
Thanks for getting back to me,
It is a UserForm I am trying to use, I have a frame containing 5 options for the user to select, these are the conditions that will always apply, i.e. location of incident.
The rest of the form has a number of checkboxes for conditions that may or may not exist.
The code I have assigned to each button takes the form of; Application.Run "'Text details.xls'!fetch_X1"
Where fetch_Road_X1 is a macro, which extracts a named range of cells from a worksheet and pastes it into specified cells in another.
As soon as a checkbox is selected the code runs and updates the relevant worksheets,
What I hope to be able to achieve; is to put the selections from one of the options buttons and any checkboxes that may be applicable into a buffer before they are executed so that the user can check the information before committing the data to the worksheet.
As it stands if the user selects the wrong checkbox, and realises his mistake early on in the form completion process, they will have to carry on to the end and rectify the error manually on as many as six worksheets., (kind of obviating the use of a userform)
I realise I need to remove the application.run condition directly from the buttons but cant figure out how to produce the intermediate step that still uses the selected option and checkboxes
Thanks once again for your suggestions
Wiggy
Ok, What you need to do is declare a Procedure level String Variable. That is put something like:
Dim sChoice as String
at the VERY top of the UserForms Private Module. Then in each OptionButton put some code that will parse the Macro name to the Variable. Then use a commandbutton to run your code:
Dim sChoice As String
Private Sub OptionButton1_Click()
sChoice = "Macro1"
End Sub
Private Sub OptionButton2_Click()
sChoice = "Macro2"
End Sub
Private Sub CommandButton1_Click()
Run sChoice
End Sub
Dave
OzGrid Business Applications