Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error and Value checking for a range of values 1

Status
Not open for further replies.

gautammalkani

Technical User
Sep 29, 2003
51
US
Hi All

I want to check a range of values (Range B9:F9) to see if they are empty or not-numeric. I have attached my code from below which shows that it works for just range B9. I tried several variations of the code but couldnt get it working. Please let me know if there is something I am doing wrong

Thanks

Gautam

' Here is the code

Private Sub PUB_Submit_BTN_Click()


' Error check before sending the data to SAP
' It also converts commas, spaces in integers and converts them to a complete number
' Displays error message and sets the erroneous data to NULL before sending the data

Dim response

If IsNumeric(Range("b9").Value) Then

If IsEmpty(Range("b9").Value) Then
response = MsgBox("You need to fill a value in cell A1", vbOKOnly, "Missing mandatory information", "DEMO.HLP", 1000)
Range("b9").Value = ""
Else
UserForm1.Show
End If
Else
response = MsgBox("Please enter numeric value", vbOKOnly, "Error in your message", "DEMO.HLP", 1000)
Range("b9").Value = ""
End If

End Sub
 
A starting point:
For Each c in Range("B9:F9")
If IsNumeric(c.Value) Then
...
End If
Next c

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top