Must Contain a Numeric Value

  • Thread starter Thread starter Paul Black
  • Start date Start date
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
 
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
 
Back
Top