Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
hi
after this line..... MyDate = DateAdd("d", 1, MyDate) add this line MyDate= Format(MyDate, "mm,dd,yy") the unexpected results (i think) is from a DateAdd format change. the line i added will put the format back to the original so that the rest of the code can put in back on the sheet the way it came off. Regards FSt1 "Steve" wrote: Thanks, but using 033109 in A1, this sub returned '4//209 --- Steve On Apr 6, 10:32 pm, Per Jessen wrote: Look at this: Sub aaa() DateString = Range("A1").Value MyMonth = Left(DateString, 2) MyDay = Mid(DateString, 3, 2) MyYear = Right(DateString, 2) MyDate = MyMonth & "/" & MyDay & "/" & MyYear MyDate = DateAdd("d", 1, MyDate) DateString = "'" & Left(MyDate, 2) & Mid(MyDate, 4, 2) & Right(MyDate, 2) Range("A1") = DateString End Sub Regards, Per On 7 Apr., 03:13, Steve wrote: I have a 6 character string of numbers in a cell which I would like to treat as a date, whereas I can add 1 to it in VBA and it would display as the following day, and then assign that value to a variable. For instance, 033109 would turn into 040109 by adding 1 to it in a procedure. Is this possible to do in a macro? Thanks... |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Convert Date string to date format | Excel Discussion (Misc queries) | |||
Search and Collect Date from Cell Containing a String with a Date | Excel Programming | |||
VBA convert day and date from text string to Excel date | Excel Programming | |||
changing a string date into a 'date' | Excel Programming | |||
Converting a string date into a Excel Date | Excel Programming |