Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 1
Default IsNumeric with array or range

I want to check a list of cells to be sure they're all numbers before
performing a computation on them. Is there a quick way (as opposed to
looping through all the cells) to check? I could set the cells up as either
an array or range but IsNumeric doesn't seem to work on either as simply
IsNumeric(MyRange). I also tried

For Each cell In MyRange
If IsNumeric(cell.Value) Then GoTo ContinueToNextCell
a = 4
Exit For
ContinueToNextCell:
Next cell

but this doesn't work because it passes logical as well as numeric values
(apparently IsNumeric treats logical values as numbers?).

Also, I can't get IsLogical or IsNumeric to work (shouldn't I be able to use
these with "xl" in front?)

thanks,
Jerry
  #2   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 35,218
Default IsNumeric with array or range

Dim myRng As Range
Set myRng = Range("a1:a10")
With myRng
If Application.Count(.Cells) = .Cells.Count Then
MsgBox "all numbers"
Else
MsgBox "not all numbers"
End If
End With

Jerry M wrote:

I want to check a list of cells to be sure they're all numbers before
performing a computation on them. Is there a quick way (as opposed to
looping through all the cells) to check? I could set the cells up as either
an array or range but IsNumeric doesn't seem to work on either as simply
IsNumeric(MyRange). I also tried

For Each cell In MyRange
If IsNumeric(cell.Value) Then GoTo ContinueToNextCell
a = 4
Exit For
ContinueToNextCell:
Next cell

but this doesn't work because it passes logical as well as numeric values
(apparently IsNumeric treats logical values as numbers?).

Also, I can't get IsLogical or IsNumeric to work (shouldn't I be able to use
these with "xl" in front?)

thanks,
Jerry


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.newusers
JMB JMB is offline
external usenet poster
 
Posts: 2,062
Default IsNumeric with array or range

Perhaps try

Application.Count(MyRange)=MyRange.Cells.Count


"Jerry M" wrote:

I want to check a list of cells to be sure they're all numbers before
performing a computation on them. Is there a quick way (as opposed to
looping through all the cells) to check? I could set the cells up as either
an array or range but IsNumeric doesn't seem to work on either as simply
IsNumeric(MyRange). I also tried

For Each cell In MyRange
If IsNumeric(cell.Value) Then GoTo ContinueToNextCell
a = 4
Exit For
ContinueToNextCell:
Next cell

but this doesn't work because it passes logical as well as numeric values
(apparently IsNumeric treats logical values as numbers?).

Also, I can't get IsLogical or IsNumeric to work (shouldn't I be able to use
these with "xl" in front?)

thanks,
Jerry

  #4   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 1
Default IsNumeric with array or range

Thanks. Both these answers worked (i can see they're basically the same.)
But I don't understand what it is about the Count property that has to do
with numerics. I thought it just counted # of cells in the range. Couldn't
find any info on it in my books or in Help.

"Dave Peterson" wrote:

Dim myRng As Range
Set myRng = Range("a1:a10")
With myRng
If Application.Count(.Cells) = .Cells.Count Then
MsgBox "all numbers"
Else
MsgBox "not all numbers"
End If
End With

Jerry M wrote:

I want to check a list of cells to be sure they're all numbers before
performing a computation on them. Is there a quick way (as opposed to
looping through all the cells) to check? I could set the cells up as either
an array or range but IsNumeric doesn't seem to work on either as simply
IsNumeric(MyRange). I also tried

For Each cell In MyRange
If IsNumeric(cell.Value) Then GoTo ContinueToNextCell
a = 4
Exit For
ContinueToNextCell:
Next cell

but this doesn't work because it passes logical as well as numeric values
(apparently IsNumeric treats logical values as numbers?).

Also, I can't get IsLogical or IsNumeric to work (shouldn't I be able to use
these with "xl" in front?)

thanks,
Jerry


--

Dave Peterson

  #5   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 35,218
Default IsNumeric with array or range

myrng.cells.count is the number of cells in myrng.

application.count is using Excel's =count() function. See excel's help (not
VBA's) for more information.



Jerry M wrote:

Thanks. Both these answers worked (i can see they're basically the same.)
But I don't understand what it is about the Count property that has to do
with numerics. I thought it just counted # of cells in the range. Couldn't
find any info on it in my books or in Help.

"Dave Peterson" wrote:

Dim myRng As Range
Set myRng = Range("a1:a10")
With myRng
If Application.Count(.Cells) = .Cells.Count Then
MsgBox "all numbers"
Else
MsgBox "not all numbers"
End If
End With

Jerry M wrote:

I want to check a list of cells to be sure they're all numbers before
performing a computation on them. Is there a quick way (as opposed to
looping through all the cells) to check? I could set the cells up as either
an array or range but IsNumeric doesn't seem to work on either as simply
IsNumeric(MyRange). I also tried

For Each cell In MyRange
If IsNumeric(cell.Value) Then GoTo ContinueToNextCell
a = 4
Exit For
ContinueToNextCell:
Next cell

but this doesn't work because it passes logical as well as numeric values
(apparently IsNumeric treats logical values as numbers?).

Also, I can't get IsLogical or IsNumeric to work (shouldn't I be able to use
these with "xl" in front?)

thanks,
Jerry


--

Dave Peterson


--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using an array range in GETPIVOTDATA Steve Excel Worksheet Functions 0 August 10th 06 07:45 PM
Dragging range (array) Rita Palazzi Excel Discussion (Misc queries) 1 June 29th 06 06:19 PM
Shapes Range Array Bubb Excel Discussion (Misc queries) 1 April 10th 06 11:51 PM
how to reverse a range/array? peter dmz Excel Worksheet Functions 5 August 11th 05 09:11 PM
opposite of IsNumeric thephoenix12 Excel Discussion (Misc queries) 10 June 24th 05 07:37 PM


All times are GMT +1. The time now is 06:47 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"