ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Validation (https://www.excelbanter.com/excel-programming/300844-validation.html)

unplugs[_4_]

Validation
 
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

--
Message posted from http://www.ExcelForum.com


unplugs[_5_]

Validation
 
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

--
Message posted from http://www.ExcelForum.com


Charles

Validation
 
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

--
Message posted from http://www.ExcelForum.com


unplugs[_6_]

Validation
 
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

--
Message posted from http://www.ExcelForum.com


Charles

Validation
 
unplug,

Check the attachment. This is what I came up with.
Range A1 is named "texthour"
Range B1 is named "textname"

HTH

Charle

Attachment filename: unplug.xls
Download attachment: http://www.excelforum.com/attachment.php?postid=57184
--
Message posted from http://www.ExcelForum.com



All times are GMT +1. The time now is 10:48 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com