ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Counting numbers (https://www.excelbanter.com/excel-programming/417677-counting-numbers.html)

Noob McKnownowt

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

Mike H

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


Noob McKnownowt

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


Dave Peterson

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


All times are GMT +1. The time now is 02:49 PM.

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