Must Contain a Numeric Value

P

Paul Black

Hi everyone,

For Sub One :-
I would like a message box to appear if the Range "B4" does NOT hold a
numeric value greater than 0 and Less Than or Equal to 13983816
please.

For Sub Two :-
I would like a message box to appear if the Range "B6:G6" does NOT
hold numeric values greater than 0 and Less Than or Equal to 49
please.

In both cases, text, blanks, zeros and nulls etc would also throw out
the message boxes, the values MUST be numeric.

Thanks in Advance.
All the Best.
Paul
 
J

JE McGimpsey

One way:

Public Sub One()
Dim bGoodValue As Boolean
With Range("B4")
If IsNumeric(.Value) Then _
bGoodValue = (.Value > 0) And (.Value < 13983816)
If Not bGoodValue Then MsgBox vbNullString
End With
End Sub


Public Sub Two()
With Range("B6:G6")
If Not Application.CountIf(.Cells, ">0") - _
Application.CountIf(.Cells, ">=49") = .Count Then _
MsgBox vbNullString
End With
End Sub
 

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

Top