Good day sir/madam!
Im using windows 7 excel 2010 and save it as xlsm
Kindly help me on my code
Code:
If (optAAA.Value) = "" Then
ElseIf (optBBB.Value) = "" Then
ElseIf (optCCC.Value) = "" Then
Else
optAAA.SetFocus
MsgBox "Pls choose product"
Exit Sub
End If
I try using this code but I got stuck on the option button maybe I'm missing something.
I also had a problem on putting a checkbox code in 'testing incomplete entry.
ORIGINAL CODE
Code:
Private Sub cmdOK_Click()
ActiveWorkbook.Sheets("Sheet1").Activate
Range("B5").Select
Do
If IsEmpty(ActiveCell) = False Then
ActiveCell.Offset(1, 0).Select
End If
Loop Until IsEmpty(ActiveCell) = True
'Test for incomplete entry
If (txtDate.Value) = "" Then
txtDate.SetFocus
MsgBox "Please enter a date of exit"
Exit Sub
End If
If (cboBranch.Value) = "" Then
cboBranch.SetFocus
MsgBox "Please enter a branch"
Exit Sub
End If
If (optAAA.Value) = "" Then
ElseIf (optBBB.Value) = "" Then
ElseIf (optCCC.Value) = "" Then
Else
optAAA.SetFocus
MsgBox "Pls choose a product"
Exit Sub
End If
ActiveCell.Value = txtDate.Value
ActiveCell.Offset(0, 1) = cboBranch.Value
ActiveCell.Offset(0, 2) = txtSName.Value
ActiveCell.Offset(0, 3) = txtFName.Value
ActiveCell.Offset(0, 4) = txtMI.Value
ActiveCell.Offset(0, 5) = txtCID.Value
If optAAA = True Then
ActiveCell.Offset(0, 6).Value = "AAA"
ElseIf optBBB = True Then
ActiveCell.Offset(0, 6).Value = "BBB"
ElseIf optCCC = True Then
ActiveCell.Offset(0, 6).Value = "CCC"
Else
ActiveCell.Offset(0, 6).Value = ""
End If
If chkXXX = True Then
ActiveCell.Offset(0, 7).Value = "XXX"
Else
ActiveCell.Offset(0, 7).Value = ""
End If
If chkYYY = True Then
ActiveCell.Offset(0, 8).Value = "YYY"
Else
ActiveCell.Offset(0, 8).Value = ""
End If
If chkZZZ = True Then
ActiveCell.Offset(0, 9).Value = "ZZZ"
Else
ActiveCell.Offset(0, 9).Value = ""
End If
'clearing forms
Range("B5").Select
txtDate.Value = ""
cboBranch.Value = ""
txtSName.Value = ""
txtFName.Value = ""
txtMI.Value = ""
txtCID.Value = ""
optAAA = False
optBBB = False
optCCC = False
chkXXX = False
chkYYY = False
chkZZZ = False
cmdExtra.SetFocus
End Sub
Thank You Very Much
Bookmarks