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

How do I check whether a certain cell has a number in it in code?

For example, i know Count(A1) gives 1 if cell A1 contains a valid
number instead of text. How do I do that in code?

I did the following but could not work:

If Count(Cell(1,1))0 Then
...
End If


---
Message posted from http://www.ExcelForum.com/

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Check for number

If Cell(1,1).value = 5 then...
et

--
Message posted from http://www.ExcelForum.com

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Check for number

no.. wat i mean is how to check that a number is entered in cell A1
instead of text.


---
Message posted from http://www.ExcelForum.com/

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 391
Default Check for number

if ISNUMERIC(cell(x,y).value) then


Patrick Molloy
Microsoft Excel MVP

-----Original Message-----
How do I check whether a certain cell has a number in it

in code?

For example, i know Count(A1) gives 1 if cell A1

contains a valid
number instead of text. How do I do that in code?

I did the following but could not work:

If Count(Cell(1,1))0 Then
...
End If


---
Message posted from http://www.ExcelForum.com/

.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 162
Default Check for number

Hi bdcrisp!

Something like:

If IsNumeric(Range("b1")) Then Range("c1") = "You have a number"



--
Regards
Norman Harker MVP (Excel)
Sydney, Australia

Excel and Word Function Lists (Classifications, Syntax and Arguments)
available free to good homes.
"courtesio99" wrote in
message ...
no.. wat i mean is how to check that a number is entered in cell A1
instead of text.


---
Message posted from
http://www.ExcelForum.com/





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Check for number

if vartype(cells(1,1).value) = vbString then msgbox "It's a string"

otherwise its a number


---
Message posted from http://www.ExcelForum.com/

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Check for number

Hi courtesio99,

IsNumeric function may can be used.
Note:Assume 3 has been inputted in A1 Cell. Nevertheless the A1 cel
has been formatted as string, IsNumeric function returns TRUE.


Code
-------------------

If IsNumeric([A1]) Then MsgBox "It's a number"

-------------------


--
Message posted from http://www.ExcelForum.com

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default Check for number

If you may have a containing a text value that looks like a number (like
'54--leading apostrophe), you can use the worksheet function:

if application.isnumber(range("a1").value) then

This'll also dump empty cells.

if isnumeric(range("a1").value) then

will show (empty) as numeric.



courtesio99 wrote:

How do I check whether a certain cell has a number in it in code?

For example, i know Count(A1) gives 1 if cell A1 contains a valid
number instead of text. How do I do that in code?

I did the following but could not work:

If Count(Cell(1,1))0 Then
..
End If

---
Message posted from http://www.ExcelForum.com/


--

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
Check number within a range djungst Excel Worksheet Functions 2 September 3rd 08 08:45 PM
How do I hide the Check Box number? ctyclrk Excel Worksheet Functions 2 April 25th 08 06:34 PM
how do i check if a number is repeating anier614 Excel Discussion (Misc queries) 4 August 17th 07 03:26 PM
how do I check if known number is in array Iain - T Excel Discussion (Misc queries) 6 January 30th 06 04:26 AM
check percentage or whole number Alan Setting up and Configuration of Excel 3 January 6th 06 08:49 PM


All times are GMT +1. The time now is 02:32 AM.

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

About Us

"It's about Microsoft Excel"