Validate values for Whole Number only

  • Thread starter Thread starter cafe
  • Start date Start date
C

cafe

Please help: How can I validate numbers enter by the user to ensur
they are not able to enter decimals. This code controls the range bu
not the decimals. Or is there a better way? Thank you.


Sub auto_open()
ThisWorkbook.Sheets("04 Est").OnEntry = "WatchIT"
End Sub

Sub WatchIT()

Dim isect As Excel.Range

Set isect = Application.Intersect(Range(ActiveCell.Address), _
Range("WatchEst04"))
If isect Is Nothing Then
Else
If (Val(ActiveCell.Value) < 0 _
Or Val(ActiveCell.Value) > 100) _
Or Not IsNumeric(ActiveCell.Value) Then
ActiveCell.Value = 0
MsgBox "No Decimals Please!!. Re-Entry "
End If
End Su
 

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