msgbox if you input text instead of numbers

  • Thread starter Thread starter T.Skogstrom
  • Start date Start date
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
 
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
 

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