ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Must Contain a Numeric Value (https://www.excelbanter.com/excel-programming/399389-must-contain-numeric-value.html)

Paul Black

Must Contain a Numeric Value
 
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


JE McGimpsey

Must Contain a Numeric Value
 
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

In article .com,
Paul Black wrote:

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



All times are GMT +1. The time now is 04:17 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com