Hello,
I try when match name in combobox1 with column B and if I select optionbutton1 or optionbutton2 and fill amount like "#,##0.00" in textbox1 then will sum over value in column C for the name based on optionbutton1,will sum over value in column D based on optionbutton2.
my problem doesn't calculate correctly when use number format and show mssage after calculation, should not show the message except in one case if I click commandbutton1 an no selected optionbuttons!
Private Sub CommandButton1_Click()
Dim f As Range
With ComboBox1
If .Value = "" Then
MsgBox "Enter Name", vbCritical
.SetFocus
Exit Sub
End If
Set f = Range("B:B").Find(.Value, , xlValues, xlWhole, , , False)
If f Is Nothing Then
MsgBox "Name does not exists", vbExclamation
.SetFocus
Exit Sub
End If
End With
With TextBox1
If .Value = "" Or Not IsNumeric(.Value) Then
MsgBox "Enter Amount", vbInformation
.SetFocus
Exit Sub
End If
End With
With f.Offset(, 1)
If OptionButton1.Value = True Then
.Value = .Value + Val(TextBox1.Value)
Else
MsgBox "No option was selected", vbCritical
End If
End With
With f.Offset(, 2)
If OptionButton2.Value = True Then
.Value = .Value + Val(TextBox1.Value)
Else
MsgBox "No option was selected", vbCritical
End If
End With
TextBox1.Value = ""
ComboBox1.Value = ""
Label4.Caption = ""
OptionButton1.Value = False
OptionButton2.Value = False
End Sub
I look forward any body to help me?