Forum Discussion
renantropico
Nov 27, 2019Copper Contributor
Import txt VBA macro changing date format in random cells
Hello! Every time that I run a vba script to import an specific txt file, it changes the date format of some cells. If I do the import manually, it doesn't change anything. I'm from Brazil so ...
alandorss
Nov 27, 2019Brass Contributor
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
Nov 27, 2019Brass Contributor
The dirty way that I had to deal with this was by literally concatenating a bunch of strings forcing formatting to be the exact way I needed it to be.
Dim strStartTime, strEndTime As String
strStartTime = Month(rpStartTime) & "/" & Day(rpStartTime) & "/" & Year(rpStartTime)
you could add in the minutes, hours, and seconds with colons need be.