Format column as Date

nniedzielski

Well-known Member
Joined
Jan 8, 2016
Messages
598
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

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
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,214,646
Messages
6,120,717
Members
448,985
Latest member
chocbudda

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