I'm currently having an issue trying to get a column which contains time and date minutes and seconds info to be reformatted into a time and date format I can then use with the filters to re-order oldest to newest etc.
here is an example of the cell entry
24/03/2021 10:30:35:540
Now, if I use the Macro recorder to record me selecting the desired column and using text to columns feature > Fixed width, take the column break line to 16 and select General for column data format, I end up with the cell entry as this below, which works with filtering.
24/03/2021 10:30:00 AM
once stop recording the Macro and review I get this below in VBA:
Columns("P:P").Select
Selection.TextToColumns Destination:=Range("P1"), DataType:=xlFixedWidth, _
FieldInfo:=Array(Array(0, 1), Array(16, 1)), TrailingMinusNumbers:=True
My issues is, when I try to run this code as a macro, it affects the dates, see explanation below, it seems to only affect dates where the format can be swapped to Americanised?
so for example original cell contains 7th March 2021
07/03/2021 05:46:45:328
When manually using text to columns, its ok, but when using VBA running above code, date and month transposes, below is results split into two columns, 3 and 7 have swapped, and now date is 3rd July
3/07/2021 5:46 :45:328
I don't really need to use text to columns feature if I don't have to, but having trouble getting the cell to convert to date and time format without it.
For example have also tried =LEFT(P2,16)
then re-pasted the columns as values then tried to use format cells > custom > d/mm/yyyy h:mm
, but that didn't work.
if anyone has any other suggestions I'm keen to hear?, hoping to be able to run something through VBA as part of a larger set of Macro's to focus is to be able to get it done via VBA.