Forum Discussion
Import txt VBA macro changing date format in random cells
renantropico Ohhh date formats. I changed my input language to german and what a pain! In anycase, have you had any luck with the format function? format(now(), "yyyy-MM-dd hh:mm:ss")
alandorss
Hey!
Thank you for the help
This works but I have more than 2000 lines to do it. It takes so long line by line.
I did this:
n = Cells(Rows.Count, "A").End(xlUp).Row
For i = 1 To n
Cells(i, 16) = Format(Cells(i, 15), "dd-mm-yyyy hh:mm:ss")
Next i
Any type to go faster?
- alandorssNov 28, 2019Brass Contributor
Hi, I found this helps quite a bit. disable calculation and also screen updating. Run the disable before the code and then enable it after. Use caution as if you hit an error, your sheet will be in calculation manual. run the enablescreenupdating by itself to change it back
Sub subDisableScreenUpdating() With Excel.Application .ScreenUpdating = FALSE .Calculation = Excel.xlCalculationManual .EnableEvents = FALSE End With End Sub Sub subEnableScreenUpdating() With Excel.Application .ScreenUpdating = TRUE .Calculation = Excel.xlCalculationAutomatic .EnableEvents = TRUE End With End Sub
Have a look but maybe there is a way to format a range vs a cell.
- renantropicoDec 02, 2019Copper Contributor
alandorss Thank you very much, this helped a lot with the long execution time.