Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 62
Default Coverting dates

Hi Group,

I have inherited a large spreadsheet full of payments
(about 5000 of them). Some dates are entered like so
01/01/04, 01/1/2004, 01.01.04, 01.1.2004.

Excel does not recognise the dates with full stops in
them. Is there a fast and efficient way for me to convert
and standardise all dates to dd/mm/yyyy?

Regards

Tony
  #2   Report Post  
Posted to microsoft.public.excel.programming
tod tod is offline
external usenet poster
 
Posts: 114
Default Coverting dates

You can use the substitute function in a formula or in
code.

In formula:

Assuming your dates are in column A, put this formula is
an empty column and fill down. Then copy the values over
those in column A. Then format the column for you
prefered date format.

=IF(LEN(SUBSTITUTE(A1,".",""))<LEN(A1),DATEVALUE
(SUBSTITUTE(A1,".","/")),A1)

This says that if the date has periods, replace them with
slashes.

In code, you do almost the same thing except that you
don't have to do the copy and pasting and formatting.

Dim Cell As Range
For Each Cell In ActiveSheet.Range("A2:A" &
ActiveSheet.Range("A65536").End(xlUp).Row)
If Len(Application.Substitute
(Cell.Value, ".", "")) < Len(Cell.Value) Then
Cell.Value = Application.Substitute
(Cell.Value, ".", "/")
Cell.NumberFormat = "dd/mm/yyyy"
End If
Next Cell

tod


-----Original Message-----
Hi Group,

I have inherited a large spreadsheet full of payments
(about 5000 of them). Some dates are entered like so
01/01/04, 01/1/2004, 01.01.04, 01.1.2004.

Excel does not recognise the dates with full stops in
them. Is there a fast and efficient way for me to

convert
and standardise all dates to dd/mm/yyyy?

Regards

Tony
.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,440
Default Coverting dates

Hi Tony,

=REPLACE(REPLACE(A1,3,1,"-"),6,1,"-")*1

Then format as date.

--

Kind Regards,

Niek Otten

Microsoft MVP - Excel

"Tony" wrote in message
...
Hi Group,

I have inherited a large spreadsheet full of payments
(about 5000 of them). Some dates are entered like so
01/01/04, 01/1/2004, 01.01.04, 01.1.2004.

Excel does not recognise the dates with full stops in
them. Is there a fast and efficient way for me to convert
and standardise all dates to dd/mm/yyyy?

Regards

Tony



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,440
Default Coverting dates

In addition to my previous reply: The "-" symbol may be "/" in your case.

--

Kind Regards,

Niek Otten

Microsoft MVP - Excel

"Tony" wrote in message
...
Hi Group,

I have inherited a large spreadsheet full of payments
(about 5000 of them). Some dates are entered like so
01/01/04, 01/1/2004, 01.01.04, 01.1.2004.

Excel does not recognise the dates with full stops in
them. Is there a fast and efficient way for me to convert
and standardise all dates to dd/mm/yyyy?

Regards

Tony



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 62
Default Coverting dates

Tod,
Thank you for the response. Apologies for not replying
sooner but have just returned from a weekend break.
I liked the VB solution.
It successfully converted the periods to dd/mm/yy but now
I cannot format them to dd/mm/yyyy. I have checked the
affected cells (about 470) under general formatting and
they do not display the Excel date function i.e. 35321.
Is it possible to convert these cells to dates?

Regards

TOny

-----Original Message-----
You can use the substitute function in a formula or in
code.

In formula:

Assuming your dates are in column A, put this formula is
an empty column and fill down. Then copy the values over
those in column A. Then format the column for you
prefered date format.

=IF(LEN(SUBSTITUTE(A1,".",""))<LEN(A1),DATEVALU E
(SUBSTITUTE(A1,".","/")),A1)

This says that if the date has periods, replace them with
slashes.

In code, you do almost the same thing except that you
don't have to do the copy and pasting and formatting.

Dim Cell As Range
For Each Cell In ActiveSheet.Range("A2:A" &
ActiveSheet.Range("A65536").End(xlUp).Row)
If Len(Application.Substitute
(Cell.Value, ".", "")) < Len(Cell.Value) Then
Cell.Value = Application.Substitute
(Cell.Value, ".", "/")
Cell.NumberFormat = "dd/mm/yyyy"
End If
Next Cell

tod


-----Original Message-----
Hi Group,

I have inherited a large spreadsheet full of payments
(about 5000 of them). Some dates are entered like so
01/01/04, 01/1/2004, 01.01.04, 01.1.2004.

Excel does not recognise the dates with full stops in
them. Is there a fast and efficient way for me to

convert
and standardise all dates to dd/mm/yyyy?

Regards

Tony
.

.

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
Coverting to minutes Gostwin Excel Discussion (Misc queries) 2 June 5th 08 10:02 PM
coverting h:mm to decimal richzip Excel Discussion (Misc queries) 2 February 15th 08 07:42 PM
Coverting seconds into hr:min:sec jsturino Excel Discussion (Misc queries) 3 March 24th 06 08:00 AM
Coverting time Kim Excel Worksheet Functions 1 September 20th 05 01:24 AM
Coverting a VBA array from 2-D to 1-D Dave[_37_] Excel Programming 20 December 15th 03 05:39 AM


All times are GMT +1. The time now is 06:03 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"