I have this problem of validating data in textbox(via userform XL
2000 with VBA(VB)6)
code]MsgBox("Please enter valid US Number.", vbOKOnly) = vbOK
Comes up with error message "LH side must have variant or object"
Here it is
Private Sub btnOK_Click()
'To enter US data & show updated calculations
Dim USNo As Integer 'From US # Textbox
Dim DateAchvd As String 'From US date achvd textbox
USNo = Int(txtUSNo.Value)
DateAchvd = txtDateAchvd.Value
'Ensure US No is enetred
If Not USNo <> "" And USNo > 56 And USNo < 20600 Then
ResultUS = MsgBox("Please enter valid US Number.", vbOKOnly)
If ResultUS = vbOK Then
txtUSNo.Value = ""
txtUSNo.SetFocus
End If
'Ensure date "dd/mm" is entered
ElseIf Not txtDateAchvd.Value <> " " Then
ResultDate = MsgBox("Please enter valid Date Format", vbOKOnly)
If ResultDate = vbOK Then
txtDateAchvd.Value = ""
txtDateAchvd.SetFocus
End If
End If
'Make sure US Prgrss is active
Sheets("US Prgss").Activate
'Find the cell with the US selected
Range("T6:CZ6").Select
Selection.Find(What:=USNo, After:=ActiveCell).Activate
ActiveCell.Offset(1, 0).Select
ActiveCell.FormulaR1C1 = DateAchvd
'ActiveCell.Offset(1, 0).Select
'ActiveCell.FormulaR1C1 = DateAchvd
txtUSNo.Value = ""
txtDateAchvd.Value = ""
ActiveCell.Range("C7").Activate
End Sub
I get an error message on the 1st "IF Not" line of code "Data
Mismatch Error 13" !!!!!
So no doubt I would get on the second MsgBox too!
Can't belive that this is so difficult!!!