Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default IsNumber in VBA (not IsNumeric)

If I enter a date in A1, say 5/10/2006, =ISNUMBER(A1) always returns TRUE.

Why does:

=wtf(A1) return FALSE for:

Function wtf(r As Range) As Boolean
wtf = Application.WorksheetFunction.IsNumber(r.Value)
End Function

??
--
Gary's Student
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 770
Default IsNumber in VBA (not IsNumeric)

Gary"s Student,

I forget the explanation for why, but it's something to do with Value and
Dates. If you change Value to Value2 it will work (or leave off the
property altogether). If you Google Dates and Value2 I think you'll find
the explanation in a past post in this group.

hth,

Doug

"Gary''s Student" wrote in message
...
If I enter a date in A1, say 5/10/2006, =ISNUMBER(A1) always returns
TRUE.

Why does:

=wtf(A1) return FALSE for:

Function wtf(r As Range) As Boolean
wtf = Application.WorksheetFunction.IsNumber(r.Value)
End Function

??
--
Gary's Student



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,316
Default IsNumber in VBA (not IsNumeric)

Would this variant work for you? If the boolean variable comes up false you
can use the VB IsDate function to see if it's a date. Apparently IsNumber
differentiates between a date value and a numeric one.

Function wtf(r As Range) As Boolean

Dim blnIsNum As Boolean

blnIsNum = Application.WorksheetFunction.IsNumber(r.Value)

If Not blnIsNum Then blnIsNum = IsDate(r.Value)

wtf = blnIsNum

End Function

--
Kevin Backmann


"Gary''s Student" wrote:

If I enter a date in A1, say 5/10/2006, =ISNUMBER(A1) always returns TRUE.

Why does:

=wtf(A1) return FALSE for:

Function wtf(r As Range) As Boolean
wtf = Application.WorksheetFunction.IsNumber(r.Value)
End Function

??
--
Gary's Student

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default IsNumber in VBA (not IsNumeric)

Doug and Kevin:

Thank you both. Using Value2 in the tiny UDF gets an exact match to using
ISNUMBER() in the worksheet.

Thanks again
--
Gary's Student


"Kevin B" wrote:

Would this variant work for you? If the boolean variable comes up false you
can use the VB IsDate function to see if it's a date. Apparently IsNumber
differentiates between a date value and a numeric one.

Function wtf(r As Range) As Boolean

Dim blnIsNum As Boolean

blnIsNum = Application.WorksheetFunction.IsNumber(r.Value)

If Not blnIsNum Then blnIsNum = IsDate(r.Value)

wtf = blnIsNum

End Function

--
Kevin Backmann


"Gary''s Student" wrote:

If I enter a date in A1, say 5/10/2006, =ISNUMBER(A1) always returns TRUE.

Why does:

=wtf(A1) return FALSE for:

Function wtf(r As Range) As Boolean
wtf = Application.WorksheetFunction.IsNumber(r.Value)
End Function

??
--
Gary's Student

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 216
Default IsNumber in VBA (not IsNumeric)

Value2 doesn't use the currency or date data types, so they become numeric.

--
HTH

Bob Phillips

(remove xxx from email address if mailing direct)

"Doug Glancy" wrote in message
...
Gary"s Student,

I forget the explanation for why, but it's something to do with Value and
Dates. If you change Value to Value2 it will work (or leave off the
property altogether). If you Google Dates and Value2 I think you'll find
the explanation in a past post in this group.

hth,

Doug

"Gary''s Student" wrote in

message
...
If I enter a date in A1, say 5/10/2006, =ISNUMBER(A1) always returns
TRUE.

Why does:

=wtf(A1) return FALSE for:

Function wtf(r As Range) As Boolean
wtf = Application.WorksheetFunction.IsNumber(r.Value)
End Function

??
--
Gary's Student







  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 770
Default IsNumber in VBA (not IsNumeric)

Bob,

So do you think my solution will work for the OP?

Thanks,

Doug

"Bob Phillips" wrote in message
...
Value2 doesn't use the currency or date data types, so they become
numeric.

--
HTH

Bob Phillips

(remove xxx from email address if mailing direct)

"Doug Glancy" wrote in message
...
Gary"s Student,

I forget the explanation for why, but it's something to do with Value and
Dates. If you change Value to Value2 it will work (or leave off the
property altogether). If you Google Dates and Value2 I think you'll find
the explanation in a past post in this group.

hth,

Doug

"Gary''s Student" wrote in

message
...
If I enter a date in A1, say 5/10/2006, =ISNUMBER(A1) always returns
TRUE.

Why does:

=wtf(A1) return FALSE for:

Function wtf(r As Range) As Boolean
wtf = Application.WorksheetFunction.IsNumber(r.Value)
End Function

??
--
Gary's Student







  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 216
Default IsNumber in VBA (not IsNumeric)

Oh yes, your suggestion was always going to work, I just finished your
explanation as to why <g

Regards

Bob

"Doug Glancy" wrote in message
...
Bob,

So do you think my solution will work for the OP?

Thanks,

Doug

"Bob Phillips" wrote in message
...
Value2 doesn't use the currency or date data types, so they become
numeric.

--
HTH

Bob Phillips

(remove xxx from email address if mailing direct)

"Doug Glancy" wrote in message
...
Gary"s Student,

I forget the explanation for why, but it's something to do with Value

and
Dates. If you change Value to Value2 it will work (or leave off the
property altogether). If you Google Dates and Value2 I think you'll

find
the explanation in a past post in this group.

hth,

Doug

"Gary''s Student" wrote in

message
...
If I enter a date in A1, say 5/10/2006, =ISNUMBER(A1) always

returns
TRUE.

Why does:

=wtf(A1) return FALSE for:

Function wtf(r As Range) As Boolean
wtf = Application.WorksheetFunction.IsNumber(r.Value)
End Function

??
--
Gary's Student








  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 770
Default IsNumber in VBA (not IsNumeric)

Thanks Bob! I appreciate it.

Doug

"Bob Phillips" wrote in message
...
Oh yes, your suggestion was always going to work, I just finished your
explanation as to why <g

Regards

Bob

"Doug Glancy" wrote in message
...
Bob,

So do you think my solution will work for the OP?

Thanks,

Doug

"Bob Phillips" wrote in message
...
Value2 doesn't use the currency or date data types, so they become
numeric.

--
HTH

Bob Phillips

(remove xxx from email address if mailing direct)

"Doug Glancy" wrote in message
...
Gary"s Student,

I forget the explanation for why, but it's something to do with Value

and
Dates. If you change Value to Value2 it will work (or leave off the
property altogether). If you Google Dates and Value2 I think you'll

find
the explanation in a past post in this group.

hth,

Doug

"Gary''s Student" wrote in
message
...
If I enter a date in A1, say 5/10/2006, =ISNUMBER(A1) always

returns
TRUE.

Why does:

=wtf(A1) return FALSE for:

Function wtf(r As Range) As Boolean
wtf = Application.WorksheetFunction.IsNumber(r.Value)
End Function

??
--
Gary's Student










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 Richard Excel Programming 3 February 26th 06 08:20 PM
vba problem with isnumeric Jean-Pierre D via OfficeKB.com Excel Programming 2 August 30th 05 10:09 AM
opposite of IsNumeric thephoenix12 Excel Discussion (Misc queries) 10 June 24th 05 07:37 PM
opposite of IsNumeric thephoenix12[_3_] Excel Programming 2 June 23rd 05 10:29 PM
IsNumeric Test scott Excel Programming 5 February 8th 05 07:59 PM


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