Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi
I have a cell which is in text format. The cell is referenced as a string. I then need to check to see if the entered date/number entered into the cell is before todays date. I use the following code to change the format of the cell number/date to become an actual date however the wrong date is shown. rngFromC = 281006 stFromaDateNameC = rngFromC If stFromDateNameC <= 999999 Then stFromDateNameC = Format(stFromDateNameC, "mm/dd/yy") stFromDateNameC = DateValue(stFromDateNameC) End If when converted into date format it shows 13/05/1969 I dont understand why it doesn't show as 28/10/06. Any idea's Thanks Noemi |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
You should use Option Explicit, you have different variable names in that
code, stFromDateNameC and stFromaDateNameC. Try this instead rngFromC = DateSerial(28, 10, 6) stFromDateNameC = rngFromC If stFromDateNameC <= 999999 Then stFromDateNameC = Format(stFromDateNameC, "mm/dd/yy") End If -- HTH Bob Phillips (replace somewhere in email address with gmail if mailing direct) "Noemi" wrote in message ... Hi I have a cell which is in text format. The cell is referenced as a string. I then need to check to see if the entered date/number entered into the cell is before todays date. I use the following code to change the format of the cell number/date to become an actual date however the wrong date is shown. rngFromC = 281006 stFromaDateNameC = rngFromC If stFromDateNameC <= 999999 Then stFromDateNameC = Format(stFromDateNameC, "mm/dd/yy") stFromDateNameC = DateValue(stFromDateNameC) End If when converted into date format it shows 13/05/1969 I dont understand why it doesn't show as 28/10/06. Any idea's Thanks Noemi |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
returned calculation incorrect | Excel Worksheet Functions | |||
IF/COUNT/AVERAGE... Value returned is incorrect. | Excel Worksheet Functions | |||
Using COS in VBA, incorrect value returned | Excel Worksheet Functions | |||
I need today's date returned as date format in formula | Excel Discussion (Misc queries) | |||
Value returned from Formula changes with the Date | Excel Worksheet Functions |