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

hey chaps,

just a quick question i am trying to write a VBA macro and i was just
wondering if there was any way i could identify a cell if its content is a
number:

e.g.

if cell.value = isanumber then
do this
else
do this
end if

any help would be very much appreciated

the noob
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Counting numbers

Hi,

You could do this

Set cell = Range("A1")
If IsNumeric(cell.Value) Then
'do this
MsgBox "Number"
Else
MsgBox "Not number"
'do this
End If


Mike


"Noob McKnownowt" wrote:

hey chaps,

just a quick question i am trying to write a VBA macro and i was just
wondering if there was any way i could identify a cell if its content is a
number:

e.g.

if cell.value = isanumber then
do this
else
do this
end if

any help would be very much appreciated

the noob

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 37
Default Counting numbers

good man

cheers pal

noob

"Mike H" wrote:

Hi,

You could do this

Set cell = Range("A1")
If IsNumeric(cell.Value) Then
'do this
MsgBox "Number"
Else
MsgBox "Not number"
'do this
End If


Mike


"Noob McKnownowt" wrote:

hey chaps,

just a quick question i am trying to write a VBA macro and i was just
wondering if there was any way i could identify a cell if its content is a
number:

e.g.

if cell.value = isanumber then
do this
else
do this
end if

any help would be very much appreciated

the noob

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Counting numbers

Just to add to Mike's response...

VBA's IsNumeric is very forgiving. If a string looks a number, then VBA's
IsNumeric will give you a true.

Excel's =isnumber() is much more stringent:

msgbox isnumeric("1E5")
msgbox application.isnumber("1E5")

Noob McKnownowt wrote:

hey chaps,

just a quick question i am trying to write a VBA macro and i was just
wondering if there was any way i could identify a cell if its content is a
number:

e.g.

if cell.value = isanumber then
do this
else
do this
end if

any help would be very much appreciated

the noob


--

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
Counting numbers yimkhoc Excel Discussion (Misc queries) 3 March 8th 10 09:56 AM
Counting Numbers Buffalo Excel Worksheet Functions 4 December 3rd 08 09:52 PM
counting numbers dmack Excel Discussion (Misc queries) 6 January 24th 07 07:50 PM
counting numbers cj21 Excel Discussion (Misc queries) 6 February 16th 06 11:28 PM
Counting numbers cj21 Excel Discussion (Misc queries) 10 February 16th 06 06:55 PM


All times are GMT +1. The time now is 09:10 AM.

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"