I have a VBA macro I wrote to fix the date in a sheet so it combines the date and time. Date is in B and is not in the format I want which is dd/mm/yyyy and time is in D and is right, hh:mm
The idea is to combine date and time and eventually end up with the correct result filling column B, overwriting what is now there. I have code working which does the combination of the date and time, as well as then selecting the cell and copying the result down to the last row of data, then copying all of that column and pasting values only into column B
Here is what I have
Sub Combine_date_and_time()
Dim ws As Worksheet
Set ws = Worksheets("predictology")
ws.Range("G2") = Application.WorksheetFunction.Text(ws.Range("B2"), "dd/mm/yyyy") & " " & Application.WorksheetFunction.Text(ws.Range("D2"), "hh:mm")
Range("G2").Select
Application.Run "PERSONAL.XLSB!CopyFormulaDownToLastRowOfData"
ws.Range("G:G").Cut
ws.Range("B2").PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False
End Sub
Two things don't work in this; firstly the copy down ends up copying the same data down, rather it calculating each cell as it would normally and I get a Runtime error 1004 Method 'PasteSpecial'of Object 'Range' failed on the paste line.
I am relatively new to writing VBA and have been browsing a number of posts and taking the relevant pieces I needed, but obviously something/s awry in my compilation of the code
Any help gladly accepted