msgbox if you input text instead of numbers

T

T.Skogstrom

Hi,

Does any of you have a minute to share with how i can validate input of a
range of a sheet and not allow other than numbers + a msgbox about that?

I already use the excel GUI "Validation" functions for other reasons, so I
need to have this in code in a worksheet_change event.

/Thanks
 
S

SunTzuComm

You could try something like this:

Dim vntCol As Variant
Dim vntRow As Variant
Dim strX As String

For Each vntRow In Selection.Rows
For Each vntCol In Selection.Columns
With ActiveSheet.Cells(vntRow.Row, vntCol.Column)
strX = .Value
If IsNumeric(strX) = False Then
strX = "Row " & CStr(vntRow.Row) & _
", Column " & CStr(vntCol.Column) & _
" is not numeric."
MsgBox strX
End If
End With
Next vntCol
Next vntRow


Regards,
Wes
 
Top