Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I am trying to do a basic macro where I do some math on a series of dates to
determine the number of days between them. In some fields in the worksheet there are entries and in some there are not. Because of this I only want to do a calculation if both fields contain data. I find that in excel the IsNumber() function will return if a date is in the field alright, but when I try to use this line in an If statement in VBA: Application.WorksheetFunction.IsNumber(Cells(row, col1).Value) FALSE is always retuned. The cell I checked has 1/5/2005 in it. I used the locals window to view the value of a temp variable I assigned and it shows "#1/5/2005#". Do I need to recast Cells(row,col1).Value as an integer and if so how do I do it? Also is there a better way to do this? |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
In VBA there is a function IsNumeric... That might be the ticket here.
-- HTH... Jim Thomlinson "brent" wrote: I am trying to do a basic macro where I do some math on a series of dates to determine the number of days between them. In some fields in the worksheet there are entries and in some there are not. Because of this I only want to do a calculation if both fields contain data. I find that in excel the IsNumber() function will return if a date is in the field alright, but when I try to use this line in an If statement in VBA: Application.WorksheetFunction.IsNumber(Cells(row, col1).Value) FALSE is always retuned. The cell I checked has 1/5/2005 in it. I used the locals window to view the value of a temp variable I assigned and it shows "#1/5/2005#". Do I need to recast Cells(row,col1).Value as an integer and if so how do I do it? Also is there a better way to do this? |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Jim that does work, additionally I also found that CLng() does a great job on
converting my date to a long so that I can check to see if it is blank (will = 0). "Jim Thomlinson" wrote: In VBA there is a function IsNumeric... That might be the ticket here. -- HTH... Jim Thomlinson "brent" wrote: I am trying to do a basic macro where I do some math on a series of dates to determine the number of days between them. In some fields in the worksheet there are entries and in some there are not. Because of this I only want to do a calculation if both fields contain data. I find that in excel the IsNumber() function will return if a date is in the field alright, but when I try to use this line in an If statement in VBA: Application.WorksheetFunction.IsNumber(Cells(row, col1).Value) FALSE is always retuned. The cell I checked has 1/5/2005 in it. I used the locals window to view the value of a temp variable I assigned and it shows "#1/5/2005#". Do I need to recast Cells(row,col1).Value as an integer and if so how do I do it? Also is there a better way to do this? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
dates on worksheets | Excel Worksheet Functions | |||
Sequential dates across worksheets | Excel Discussion (Misc queries) | |||
changing dates in worksheets - help | Excel Discussion (Misc queries) | |||
Moving dates between worksheets | Excel Discussion (Misc queries) | |||
Dates to Worksheets | Excel Programming |