Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default date data type is not a date??

Following is code I am running. I intend to compare two dates. One date
(orderrg.value) is from a spreadsheet and is defined as a type date. The
other date is the system date. However when I check to see if the
orderrg.value is a date via ISDATE, it fails. Following the code is the
prinout from the immediate window. It looks to me like it should be able to
recognize it as a date, but yet it doesn't. Does anyone have any ideas?


Private Sub Workbook_Open()

Dim wscommission As Worksheet
Dim nindex As Integer
Dim lastorder As Integer
Dim sheetname As String
Dim orderws As Worksheet
Dim orderrg As range

Set wscommission = ThisWorkbook.Worksheets("commission")
Application.Cursor = xlNorthwestArrow

'DETERMINE IF ANY ORDERS ARE READY TO APPLY TO COMMISSION

Debug.Print Date

lastorder = ThisWorkbook.Worksheets.count - 8 'sets ending range to 'the
last possible order
Debug.Print lastorder
For nindex = 3 To lastorder 'process 1st order thru the last order
sheetname = ThisWorkbook.Worksheets(nindex).Name 'set up the sheetname
Debug.Print sheetname
'Sheets(sheetname).Select
Debug.Print ActiveWorkbook.Sheets(sheetname).Tab.ColorIndex
'PROCESS THRU THE ORDERS WHOSE COLOR IS LIGHT GREEN (CARRIER HAS BEEN
ASSIGNED)
If ActiveWorkbook.Sheets(sheetname).Tab.ColorIndex = 35 Then
'IF THE ORDER'S DELV DATE IS LESS THAN THE CURRENT DATE; PROCESS IT
Set orderws = ThisWorkbook.Worksheets(sheetname)
Set orderrg = orderws.range("E24")
Debug.Print orderrg.Value
'Dorderdate = CDate(orderrg.Value)
' orderdate = orderrg.Value

If IsDate(Date) Then
If IsDate(orderrg.Value) Then
'include code to compare the dates once I get valid dates
Else
GoTo usererror
End If
Else
GoTo usererror
End If
Else
Exit Sub
End If
Next

usererror:
Debug.Print "date invalid"

End Sub


HERE IS THE DISPLAY FROM THE IMMEDIATE WINDOW
4/22/2010
3
D100001
35
2/29/2010
date invalid
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default date data type is not a date??

2010 isn't a leap year, so 2/29/2010 isn't a date.



Phyllis wrote:

Following is code I am running. I intend to compare two dates. One date
(orderrg.value) is from a spreadsheet and is defined as a type date. The
other date is the system date. However when I check to see if the
orderrg.value is a date via ISDATE, it fails. Following the code is the
prinout from the immediate window. It looks to me like it should be able to
recognize it as a date, but yet it doesn't. Does anyone have any ideas?

Private Sub Workbook_Open()

Dim wscommission As Worksheet
Dim nindex As Integer
Dim lastorder As Integer
Dim sheetname As String
Dim orderws As Worksheet
Dim orderrg As range

Set wscommission = ThisWorkbook.Worksheets("commission")
Application.Cursor = xlNorthwestArrow

'DETERMINE IF ANY ORDERS ARE READY TO APPLY TO COMMISSION

Debug.Print Date

lastorder = ThisWorkbook.Worksheets.count - 8 'sets ending range to 'the
last possible order
Debug.Print lastorder
For nindex = 3 To lastorder 'process 1st order thru the last order
sheetname = ThisWorkbook.Worksheets(nindex).Name 'set up the sheetname
Debug.Print sheetname
'Sheets(sheetname).Select
Debug.Print ActiveWorkbook.Sheets(sheetname).Tab.ColorIndex
'PROCESS THRU THE ORDERS WHOSE COLOR IS LIGHT GREEN (CARRIER HAS BEEN
ASSIGNED)
If ActiveWorkbook.Sheets(sheetname).Tab.ColorIndex = 35 Then
'IF THE ORDER'S DELV DATE IS LESS THAN THE CURRENT DATE; PROCESS IT
Set orderws = ThisWorkbook.Worksheets(sheetname)
Set orderrg = orderws.range("E24")
Debug.Print orderrg.Value
'Dorderdate = CDate(orderrg.Value)
' orderdate = orderrg.Value

If IsDate(Date) Then
If IsDate(orderrg.Value) Then
'include code to compare the dates once I get valid dates
Else
GoTo usererror
End If
Else
GoTo usererror
End If
Else
Exit Sub
End If
Next

usererror:
Debug.Print "date invalid"

End Sub

HERE IS THE DISPLAY FROM THE IMMEDIATE WINDOW
4/22/2010
3
D100001
35
2/29/2010
date invalid


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default date data type is not a date??

Thank you Dave,
boy do I feel stupid. I was so busy concentrating on what was wrong with
the date format that it never occured to me.

"Dave Peterson" wrote:

2010 isn't a leap year, so 2/29/2010 isn't a date.



Phyllis wrote:

Following is code I am running. I intend to compare two dates. One date
(orderrg.value) is from a spreadsheet and is defined as a type date. The
other date is the system date. However when I check to see if the
orderrg.value is a date via ISDATE, it fails. Following the code is the
prinout from the immediate window. It looks to me like it should be able to
recognize it as a date, but yet it doesn't. Does anyone have any ideas?

Private Sub Workbook_Open()

Dim wscommission As Worksheet
Dim nindex As Integer
Dim lastorder As Integer
Dim sheetname As String
Dim orderws As Worksheet
Dim orderrg As range

Set wscommission = ThisWorkbook.Worksheets("commission")
Application.Cursor = xlNorthwestArrow

'DETERMINE IF ANY ORDERS ARE READY TO APPLY TO COMMISSION

Debug.Print Date

lastorder = ThisWorkbook.Worksheets.count - 8 'sets ending range to 'the
last possible order
Debug.Print lastorder
For nindex = 3 To lastorder 'process 1st order thru the last order
sheetname = ThisWorkbook.Worksheets(nindex).Name 'set up the sheetname
Debug.Print sheetname
'Sheets(sheetname).Select
Debug.Print ActiveWorkbook.Sheets(sheetname).Tab.ColorIndex
'PROCESS THRU THE ORDERS WHOSE COLOR IS LIGHT GREEN (CARRIER HAS BEEN
ASSIGNED)
If ActiveWorkbook.Sheets(sheetname).Tab.ColorIndex = 35 Then
'IF THE ORDER'S DELV DATE IS LESS THAN THE CURRENT DATE; PROCESS IT
Set orderws = ThisWorkbook.Worksheets(sheetname)
Set orderrg = orderws.range("E24")
Debug.Print orderrg.Value
'Dorderdate = CDate(orderrg.Value)
' orderdate = orderrg.Value

If IsDate(Date) Then
If IsDate(orderrg.Value) Then
'include code to compare the dates once I get valid dates
Else
GoTo usererror
End If
Else
GoTo usererror
End If
Else
Exit Sub
End If
Next

usererror:
Debug.Print "date invalid"

End Sub

HERE IS THE DISPLAY FROM THE IMMEDIATE WINDOW
4/22/2010
3
D100001
35
2/29/2010
date invalid


--

Dave Peterson
.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default date data type is not a date??

Sometimes, those kinds of errors just need an extra pair of eyes.

Phyllis wrote:

Thank you Dave,
boy do I feel stupid. I was so busy concentrating on what was wrong with
the date format that it never occured to me.

"Dave Peterson" wrote:

2010 isn't a leap year, so 2/29/2010 isn't a date.



Phyllis wrote:

Following is code I am running. I intend to compare two dates. One date
(orderrg.value) is from a spreadsheet and is defined as a type date. The
other date is the system date. However when I check to see if the
orderrg.value is a date via ISDATE, it fails. Following the code is the
prinout from the immediate window. It looks to me like it should be able to
recognize it as a date, but yet it doesn't. Does anyone have any ideas?

Private Sub Workbook_Open()

Dim wscommission As Worksheet
Dim nindex As Integer
Dim lastorder As Integer
Dim sheetname As String
Dim orderws As Worksheet
Dim orderrg As range

Set wscommission = ThisWorkbook.Worksheets("commission")
Application.Cursor = xlNorthwestArrow

'DETERMINE IF ANY ORDERS ARE READY TO APPLY TO COMMISSION

Debug.Print Date

lastorder = ThisWorkbook.Worksheets.count - 8 'sets ending range to 'the
last possible order
Debug.Print lastorder
For nindex = 3 To lastorder 'process 1st order thru the last order
sheetname = ThisWorkbook.Worksheets(nindex).Name 'set up the sheetname
Debug.Print sheetname
'Sheets(sheetname).Select
Debug.Print ActiveWorkbook.Sheets(sheetname).Tab.ColorIndex
'PROCESS THRU THE ORDERS WHOSE COLOR IS LIGHT GREEN (CARRIER HAS BEEN
ASSIGNED)
If ActiveWorkbook.Sheets(sheetname).Tab.ColorIndex = 35 Then
'IF THE ORDER'S DELV DATE IS LESS THAN THE CURRENT DATE; PROCESS IT
Set orderws = ThisWorkbook.Worksheets(sheetname)
Set orderrg = orderws.range("E24")
Debug.Print orderrg.Value
'Dorderdate = CDate(orderrg.Value)
' orderdate = orderrg.Value

If IsDate(Date) Then
If IsDate(orderrg.Value) Then
'include code to compare the dates once I get valid dates
Else
GoTo usererror
End If
Else
GoTo usererror
End If
Else
Exit Sub
End If
Next

usererror:
Debug.Print "date invalid"

End Sub

HERE IS THE DISPLAY FROM THE IMMEDIATE WINDOW
4/22/2010
3
D100001
35
2/29/2010
date invalid


--

Dave Peterson
.


--

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
My date is coming up 0-Jan-00 when I type current date. Why? Clark Excel Discussion (Misc queries) 5 January 5th 10 05:59 PM
Character Month from Date Data type Vikas Kale Excel Programming 1 November 6th 07 08:07 AM
This date 20071017072917 into this type of date 10/17/2007 29:17 Micro Excel Discussion (Misc queries) 3 October 17th 07 05:58 PM
Problems with DATE data type dmplacebo[_3_] Excel Programming 2 July 12th 05 10:36 AM
Problems with DATE data type dmplacebo New Users to Excel 0 July 12th 05 08:40 AM


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