Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 149
Default IsNumeric Test

I'm trying to test the cells A2 to C2 to see if any cells do not contain
numerical values. Can someone help me with below code? I'm getting an error
saying "sub or function not defined." I am running it from an add-in and may
need it to set "sheet1" as the target spreadsheet, but didn't know syntax.

For Each cell In Me.Range("A2:C2")

Select Case IsNumeric(cell.Value)
Case True
MsgBox "a1 numeric"
Case False
MsgBox "a1 non numeric"
Case Else
MsgBox "Don't know"
End Select
Next


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,327
Default IsNumeric Test


For Each cell In ActiveWorkbook.Sheets("sheet1").Range("A2:C2")

HTH. Best wishes Harald

"scott" skrev i melding
...
I'm trying to test the cells A2 to C2 to see if any cells do not contain
numerical values. Can someone help me with below code? I'm getting an

error
saying "sub or function not defined." I am running it from an add-in and

may
need it to set "sheet1" as the target spreadsheet, but didn't know syntax.

For Each cell In Me.Range("A2:C2")

Select Case IsNumeric(cell.Value)
Case True
MsgBox "a1 numeric"
Case False
MsgBox "a1 non numeric"
Case Else
MsgBox "Don't know"
End Select
Next




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 149
Default IsNumeric Test

It now checks the cells, but IsNumeric() returns True for empty cells, why
does that happen?


"Harald Staff" wrote in message
...

For Each cell In ActiveWorkbook.Sheets("sheet1").Range("A2:C2")

HTH. Best wishes Harald

"scott" skrev i melding
...
I'm trying to test the cells A2 to C2 to see if any cells do not contain
numerical values. Can someone help me with below code? I'm getting an

error
saying "sub or function not defined." I am running it from an add-in and

may
need it to set "sheet1" as the target spreadsheet, but didn't know
syntax.

For Each cell In Me.Range("A2:C2")

Select Case IsNumeric(cell.Value)
Case True
MsgBox "a1 numeric"
Case False
MsgBox "a1 non numeric"
Case Else
MsgBox "Don't know"
End Select
Next






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default IsNumeric Test

isnumeric tests if the value can be evaluated as a number. A blank cell can
be evaluated as zero, so it is true.

Just check if it is empty before checking if it is numeric.

--
Regards,
Tom Ogilvy

"scott" wrote in message
...
It now checks the cells, but IsNumeric() returns True for empty cells, why
does that happen?


"Harald Staff" wrote in message
...

For Each cell In ActiveWorkbook.Sheets("sheet1").Range("A2:C2")

HTH. Best wishes Harald

"scott" skrev i melding
...
I'm trying to test the cells A2 to C2 to see if any cells do not

contain
numerical values. Can someone help me with below code? I'm getting an

error
saying "sub or function not defined." I am running it from an add-in

and
may
need it to set "sheet1" as the target spreadsheet, but didn't know
syntax.

For Each cell In Me.Range("A2:C2")

Select Case IsNumeric(cell.Value)
Case True
MsgBox "a1 numeric"
Case False
MsgBox "a1 non numeric"
Case Else
MsgBox "Don't know"
End Select
Next








  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,651
Default IsNumeric Test

On Tue, 8 Feb 2005 11:14:43 -0600, "scott" wrote:

It now checks the cells, but IsNumeric() returns True for empty cells, why
does that happen?


Because a blank can be evaluated as a number.

If you want to look for a number being present, as opposed to contents which
can be evaluated as a number, try:

application.WorksheetFunction.IsNumber


--ron


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default IsNumeric Test

I placed this in a sheet module as the click event for a command button and
it worked fine:

Private Sub CommandButton1_Click()
For Each cell In Me.Range("A2:C2")

Select Case IsNumeric(cell.Value)
Case True
MsgBox "a1 numeric"
Case False
MsgBox "a1 non numeric"
Case Else
MsgBox "Don't know"
End Select
Next


End Sub


If it isn't in a sheet module, then the use of ME would be meaningless. In
a sheet module, it refers to the sheet containing the code.

--
Regards,
Tom Ogilvy


"scott" wrote in message
...
I'm trying to test the cells A2 to C2 to see if any cells do not contain
numerical values. Can someone help me with below code? I'm getting an

error
saying "sub or function not defined." I am running it from an add-in and

may
need it to set "sheet1" as the target spreadsheet, but didn't know syntax.

For Each cell In Me.Range("A2:C2")

Select Case IsNumeric(cell.Value)
Case True
MsgBox "a1 numeric"
Case False
MsgBox "a1 non numeric"
Case Else
MsgBox "Don't know"
End Select
Next




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
IsNumeric with array or range Jerry M New Users to Excel 4 April 24th 07 01:29 PM
Calculate mean of test scores from rows of test answers RiotLoadTime Excel Discussion (Misc queries) 1 July 26th 06 05:14 PM
opposite of IsNumeric thephoenix12 Excel Discussion (Misc queries) 10 June 24th 05 07:37 PM
Not IsNumeric not working - or is it me? Ed Excel Programming 3 January 6th 05 11:30 PM
check Isnumeric, doesnot work well helmekki[_17_] Excel Programming 3 August 7th 04 03:34 AM


All times are GMT +1. The time now is 12:16 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"