ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Test cells within Range("S16:S19) are NOT Numbers (https://www.excelbanter.com/excel-programming/341176-test-cells-within-range-s16-s19-not-numbers.html)

CRayF

Test cells within Range("S16:S19) are NOT Numbers
 
Can I test for a range of 4 cells in the same column to be numbers?
If any of the cells within Range("S16:S19) are NOT Numbers then MsgBos
Else


Dave Peterson

Test cells within Range("S16:S19) are NOT Numbers
 
dim myRng as range
with activesheet
set myrng = .range("s16:S19")
end with

if application.count(myrng) = myrng.cells.count then
'all numbers
else
'not all numbers
end if



CRayF wrote:

Can I test for a range of 4 cells in the same column to be numbers?
If any of the cells within Range("S16:S19) are NOT Numbers then MsgBos
Else


--

Dave Peterson

CRayF

Test cells within Range("S16:S19) are NOT Numbers
 
Way new at this and Im not sure how to add this within my loop...

My current code this. It loops but for this eample lets assume j=11...
I am currently using the Application.CountA.Range testing Range.Count but
this seems not to work, if I change it to test looing for numbers I know that
will...
So, How could I augment this stamtment using your sugestion for testing for
numners?

If Target.Address = "$S$4" And ActiveSheet.Name < _
srcBettingTemplateWs.Name Then
srcBettingTemplateWs.Unprotect
If Application.CountA(Range("S" & j + 5 & ":S" & j + 8)) < _
Range("S" & j + 5 & ":S" & j + 8).Count Then
'At least one of your racers are missing.
'code here
Else
'No racers are missing.
End If
End If

"Dave Peterson" wrote:

dim myRng as range
with activesheet
set myrng = .range("s16:S19")
end with

if application.count(myrng) = myrng.cells.count then
'all numbers
else
'not all numbers
end if


Dave Peterson

Test cells within Range("S16:S19) are NOT Numbers
 
Change application.countA to application.count

Excel's help (Not VBA's) will explain the difference between the two.

Personally, I like myrng.cells.count instead of myrng.count--just because I
think the first is more "self-documenting". But both will count the number of
cells in that range.



CRayF wrote:

Way new at this and Im not sure how to add this within my loop...

My current code this. It loops but for this eample lets assume j=11...
I am currently using the Application.CountA.Range testing Range.Count but
this seems not to work, if I change it to test looing for numbers I know that
will...
So, How could I augment this stamtment using your sugestion for testing for
numners?

If Target.Address = "$S$4" And ActiveSheet.Name < _
srcBettingTemplateWs.Name Then
srcBettingTemplateWs.Unprotect
If Application.CountA(Range("S" & j + 5 & ":S" & j + 8)) < _
Range("S" & j + 5 & ":S" & j + 8).Count Then
'At least one of your racers are missing.
'code here
Else
'No racers are missing.
End If
End If

"Dave Peterson" wrote:

dim myRng as range
with activesheet
set myrng = .range("s16:S19")
end with

if application.count(myrng) = myrng.cells.count then
'all numbers
else
'not all numbers
end if


--

Dave Peterson


All times are GMT +1. The time now is 09:20 PM.

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