In order to combine a cell that has a date with a cell that has a time, using a Macro and VBA in Excel, you must sum the data.
For instance, if you have one cell formatted as a date and another cell formatted as a time and you want to combine them into a single cell with the date and time together, you cannot simply concatenate the data.
If the date is in cell A1 and the time in cell B1 and you want to combine them in cell C1, you must do something like this:
Sub CombineDateTime()
Range("C1").Value = Range("A1").Value + Range("B1").Value
End Sub
Notice the plus sign in between the Range for A1 and B1.
It is easy to think that you should simply concatenate these two values and then put that into a cell but this will not work. Remember that dates and times are stored as numbers in Excel. This is why you need to sum or add these date and time values in order to get the correct result.
Also, in case Excel does not automatically format the destination cell as you would like, remember to ensure that the correct date/time formatting is being used, whichever you want, as this can dramatically change the visible output of a cell containing a date and time value.
I hope this was helpful! Remember to share this tutorial and follow us on Google Plus!