Question : Dates will not format properly  (month and day)

We have a huge spreadsheet in which one column contains dates.  We want the dates to be formatted as "mm/dd/yyyy" and I have applied a custom format to the column.  However, many of the dates refuse to format properly.  We'll get about halfway down and they are formatted as 9/7/2004.  There doesn't seem to be a problem with the years... just the month and day.  Also, prior to this we tried to format the dates as "mm/dd/yy" and every time we clicked in the cell again, it changed the year to yyyy.  

Very odd.

I've tried converting it to a different version of Excel, copied and pasted values, etc. etc.

Any other suggestions?

Answer : Dates will not format properly  (month and day)

Hi Joanne,
Are those dates text that looks like dates perhaps? If so, they won't change appearance when you format them.

Two easy ways to convert them are:
1) Copy a blank cell
2) Select the cells to convert
3) Edit...Paste Special...Add
4) Format the cells as desired

A macro to do this is quite simple. It goes in a regular module sheet. To use it, select the cells to be converted, then run the macro. The macro will ask you to point to a cell with the desired date/time or number format.
Sub TextToNumbers()
Dim cel As Range, rg As Range
On Error Resume Next
Set rg = Selection
Set cel = Application.InputBox("Please pick a cell that has the desired number format", Type:=8)
If Not cel Is Nothing Then
    rg.NumberFormat = cel.NumberFormat
    rg.Value = rg.Value
End If
On Error GoTo 0
End Sub

Another way to convert text to numbers uses the Data...Text to Columns menu item. One benefit of this approach is that you can specify the format of dates (such as if they were exported with leading zeros as mmddyy). You can also throw away part of the data (if you want).
1) Select the cells to be converted
2) Open the Data...Text to Columns menu item
3) In the first step of the wizard, choose "Delimited" ("Fixed if you want to get rid of certain information)
4) Click "Next" twice
5) In the third step of the wizard, you can specify whether a column contains text or dates. Choose General if the column contains numbers. If you choose Dates, specify the format in the dropdown to the right.
6) Click "Finish"

Cheers!

Brad
Random Solutions  
 
programming4us programming4us