Validation

  • Thread starter Thread starter unplugs
  • Start date Start date
U

unplugs

How can i do the validation that if I want the data to be insert i
integer? If other then integer, an error msg will pop up.

My code is as follow:


If TextHours.Value = "" Then
MsgBox "You must enter a value in working hour."
Exit Sub


I had tried before the code following... but cannot work

If TextHours.Value = "" Or TextHours.Value <> int Then
MsgBox "You must enter a value in working hour."
Exit Sub


Can u all point out what is the mistake that I had done
 
and 1 more question.... what is the VBA code that do the validation tha
cannot have duplicate entries ?

For example, cannot have 2 different id for the entries
 
Hi,

Try,

Sub nonnum()
Application.ScreenUpdating = False
Worksheets("sheet1").Activate
If Not (IsNumeric(Range("b1").Value)) Then
MsgBox "Last Backup was on: " & Range("b1").Value
End If
End Sub


Hope this gets you started

Charle
 
Thanks for the reply, Charles... Anyway... It cannot help solve m
problem. My codes are as follow:

If TextName.Text = "" Then
MsgBox "You must enter a name."
Exit Sub
End If

If TextHours.Value = "" Then
MsgBox "You must enter a value in working hour."
Exit Sub
Else
If TextHours.Value > 8 Then
OT = TextHours.Value - 8
MsgBox "Your OT is," & OT
End If
End If




I want to do the validation so that the TextHours.Value can just accep
the integer numbers only. If user key in alphabet or any sign inside
it will pop up an error msg.

Hope u can help me to solve this problem... THank
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top