I have the following code that formats some of the columns in my Excel worksheet:
Dim rng2 As Long
rng2 = .Range("A" & Rows.Count).End(xlUp).Row
.Range("N2:N" & rng2).Style = "Currency"
.Range("A1:R" & rng2).Columns.AutoFit
Now I want to format column F to show the date and time in the following format: mm/dd/yyyy hh:mm AM/PM
But I'm not able to do so, here's what I've tried so far:
.Range("F2:F" & rng2).NumberFormat = "mm/dd/yyyy hh:mm AM/PM"
.Range("F2:F" & rng2) = Format("mm/dd/yyyy hh:mm AM/PM")
Thank you in advance.