Format column as Date

nniedzielski

Well-known Member
Joined
Jan 8, 2016
Messages
590
Office Version
  1. 2019
Platform
  1. Windows
I am trying to format an entire column as a date in this format "mm.dd.yyyyhh:mm"

It is not working properly,

Code:
Range("D:D") = Format("mm.dd.yyyyhh:mm")

is there something i am missing?
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
68,115
Office Version
  1. 365
Platform
  1. Windows
A little secret.
Turn on the Macro Recorder, and record yourself doing this manually on your sheet column, and you will have the VBA code that you need!

It will look something like this:
Code:
    Columns("D:D").Select
    Selection.NumberFormat = "mm.dd.yyyyhh:mm"
This will work fine, but note that Selects are usually not necessary, and whenever you have a Select followed by a Selection, you can combine the two rows into one like this:
Code:
    Columns("D:D").NumberFormat = "mm.dd.yyyyhh:mm"
It just makes your code a little faster to remove any unnecessary Selects.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,196,007
Messages
6,012,829
Members
441,732
Latest member
Ayon

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
Top