jewkes6000
Board Regular
- Joined
- Mar 25, 2020
- Messages
- 60
- Office Version
- 365
- Platform
- Windows
I have a macro which calls a User Form to give the user the option to select from a list (from a listbox). On this UserForm, there is also a button to click ("CommandButton_NoChange") if they don't want to select from the listbox. After the user selects something from the user form, it then comes back to my original macro. If they choose something from the listbox, I assign it to "Location". This works fine. But if they don't choose from the listbox and click the button ("CommandButton_NoChange"), I can't seem to run an if statement to determine if the button was clicked or not. In the example below, I tried testing if the button value was "True", but even if I click the button, the button value remains false making this if statement worthless. How can I determine if the button was clicked in the UserForm and then use that information to continue my code?
Here is my code:
I have also tried setting the Command Button value to true within the UserForm code, but this doesn't work either.
Here is my code:
VBA Code:
UserForm_Location_RiskItem.Repaint
UserForm_Location_RiskItem.Show
Location = UserForm_Location_RiskItem.ListBox_PrjList.Value
If UserForm_Location_RiskItem.CommandButton_NoChange = True Then
Range("Y39").Select
End If
I have also tried setting the Command Button value to true within the UserForm code, but this doesn't work either.
VBA Code:
Private Sub CommandButton_NoChange_Click()
UserForm_Location_RiskItem.Hide
UserForm_Location_RiskItem.CommandButton_NoChange = True
End Sub
Last edited: