Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 72
Default Problem with Date Conversion Code

I have the below code that is part of an existing macro to change my date in
Column C from this odd format of

Y/MM/DD to MM/DD/YYYY

however it is not calculating correctly. Here are a few examples of the
coversion after the macro is run

"60526" converted to "26/05/2006"
"60523" converted to "23/05/2006"

I need to change where the month is to where the day is and where the day is
to the month.

With Selection

Dim RowNum As Integer
Dim NextValue As String
Dim NextDate As Date

For RowNum = 2 To Range("C1").CurrentRegion.Rows.Count
NextValue = Range("C" & RowNum).Value
NextDate = DateSerial(2000 + Mid(NextValue, 1, 1), Mid(NextValue, 2,
2), Mid(NextValue, 4, 2))
Range("C" & RowNum).NumberFormat = "dd/mm/yyyy"
Range("C" & RowNum).Value = NextDate
Next RowNum

End With
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
Static Date and Time code problem Laura Excel Discussion (Misc queries) 12 August 31st 07 07:04 AM
Date Conversion Problem sixwest Excel Discussion (Misc queries) 1 June 23rd 06 06:15 PM
problem regarding date conversion ashishprem[_3_] Excel Programming 1 February 13th 06 02:19 PM
Problem with Date format from VBA code twig Excel Discussion (Misc queries) 3 December 7th 04 06:01 PM
Date problem from code to text box to spreadsheet Joe 90[_2_] Excel Programming 2 October 20th 03 11:18 PM


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