All,
Situation: Very large list of dates in column A (approximately 300-400K values) formatted as "m/d/yyyy h:mm"
Desire: Way to paste these values in Bx, Cx, and Dx each with different format for each value of x until row count.
Issue: My code literally takes 30 minutes and this step is just the first part of the code for the complete macro
Question: Is there a better way to write my code that it doesn't take so long? I'm pretty sure it's inefficient.
Bonus: I'd like to just delete the original date column once all is said and done with the loop automatically.
Example of what I'd like to accomplish:
For x = 2 to row count
Given A2 = 11/1/2018 8:59:59 AM (m/d/yyyy h:mm)
Make B2 = Nov-2018 (mmm-yyyy)
Make C2 = Nov-01 (mmm-dd)
Make D2 = 8:00 AM (needs to be rounded down to the nearest whole hour)
Sub DateCopy()
Dim lastrow As Long
Dim x As Integer
Dim y As Date
Range("B1") = "MONTH-YEAR"
Range("C1") = "MONTH-DAY"
Range("D1") = "TIME"
With Worksheets("Sheet1")
lastrow = .Cells(.Rows.Count, 1).End(xlUp).Row
For x = 2 To lastrow
Range("A" & x).Copy Range("B" & x)
Range("B" & x).NumberFormat = "mmm-yyy"
Range("A" & x).Copy Range("C" & x)
Range("C" & x).NumberFormat = "mmm-dd"
Range("A" & x).Copy Range("D" & x)
Range("D" & x).NumberFormat = "[$-en-US]h:mm:ss.000 AM/PM"
Next x
End With
End Sub
Thank you!
Bookmarks