Hello
I have to optionbutton 1,2 inside the sheet(not on userform)
and I have code in commandbutton 1
if I put this procedure before my code
and the option button1,2
so if two option buttons are false,then will show message box when click commandbutton1 , and if one of the option button is true then should run the code without show message , but it always will show the message , how I can fix it?
so if the G1=PURCHASE OR SALES based on optionbutton1 or 2 then should run the code in commandbutton1 .
if the G1= empty or equal different word then should show message.
thanks
I have to optionbutton 1,2 inside the sheet(not on userform)
and I have code in commandbutton 1
if I put this procedure before my code
VBA Code:
Private Sub CommandButton1_Click()
If Sheets("DATA").Range("G1") <> "PURCHASE" Or Sheets("DATA").Range("G1") = "SALES" Then
MsgBox "please select one of the optionbutton ", vbCritical
Exit Sub
End If
'rest of the code
'
'
VBA Code:
Private Sub OptionButton1_Click()
'code
'
'
If OptionButton1.Value = True Then Sheets("DATA").Range("G1") = "SALES"
End Sub
Private Sub OptionButton2_Click()
'code
'
'
If OptionButton2.Value = True Then Sheets("DATA").Range("G1") = "PURCHASE"
End Sub
so if the G1=PURCHASE OR SALES based on optionbutton1 or 2 then should run the code in commandbutton1 .
if the G1= empty or equal different word then should show message.
thanks