Cell Format Difference

AlexanderBB

Well-known Member
Joined
Jul 1, 2009
Messages
2,038
Office Version
  1. 2019
  2. 2010
Platform
  1. Windows
A Column in my worksheet holds dates
Format Cells - Number - Category is set to Custom and Type is dd mmm yyyy

Most of the entries in this column display like this in the Formula bar, or if read with VBA.
But some of them are in format dd/mm/yyyy.

All are dd mmm yyyy looking at the worksheet and right click "Format Cells" settings are the same.
Is there a reason for the difference and any suggestions for a 'fix' ? Thank you.
 
That would be ok ?
You're best placed to test it. It's your data.

But it will be quicker not to loop:

VBA Code:
Sub CustomToText()
    
    With Range("V2:V18609")
        .NumberFormat = "@"
        .Value = Evaluate("Text(" & .Address & ",""dd mmm yyyy"")")
    End With
    
End Sub
 
Upvote 0

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
If cl.NumberFormat = "dd mmm yyyy" ....
If you decide you do want numeric dates, then perhaps:

Code:
Sub CustomToDate()
    
    With Range("V2:V18609")
        .NumberFormat = "dd mmm yyyy"
        .Value = Evaluate("Datevalue(" & .Address & ")")
    End With
    
End Sub
 
Upvote 0
Good to know. I had this weird idea if the cell wasn't cleared the new format would not be applied.
 
Upvote 0

Forum statistics

Threads
1,223,016
Messages
6,169,628
Members
452,268
Latest member
kachauya

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top