Hi,
I'm copying multiple time values into a single cell using vba with a space as a separator, however it is resulting in a cell with a bunch of numbers and I am unable to format it back into time.
Snipaste_2023-02-27_09-49-52.pngSnipaste_2023-02-27_09-49-52.png
Is there anyway to convert into time format?
This is the macro I'm using to copy the cells:
where ws1.Cells(y,"E") contains the time values I want to copy
For y = 2 To 3024
If ws1.Cells(y, "A").Value = ws2.Cells(x, "A").Value Then
If ws1.Cells(y, "E") = "6/02/2023" Then
ws3.Cells(x, "B").Value = ws3.Cells(x, "B").Value & " " & ws1.Cells(y, "F")
ElseIf ws1.Cells(y, "E") = "7/02/2023" Then
ws3.Cells(x, "C").Value = ws3.Cells(x, "C").Value & " " & ws1.Cells(y, "F")
ElseIf ws1.Cells(y, "E") = "8/02/2023" Then
ws3.Cells(x, "D").Value = ws3.Cells(x, "D").Value & " " & ws1.Cells(y, "F")
ElseIf ws1.Cells(y, "E") = "9/02/2023" Then
ws3.Cells(x, "E").Value = ws3.Cells(x, "E").Value & " " & ws1.Cells(y, "F")
ElseIf ws1.Cells(y, "E") = "10/02/2023" Then
ws3.Cells(x, "F").Value = ws3.Cells(x, "F").Value & " " & ws1.Cells(y, "F")
ElseIf ws1.Cells(y, "E") = "11/02/2023" Then
ws3.Cells(x, "G").Value = ws3.Cells(x, "G").Value & " " & ws1.Cells(y, "F")
ElseIf ws1.Cells(y, "E") = "12/02/2023" Then
ws3.Cells(x, "H").Value = ws3.Cells(x, "H").Value & " " & ws1.Cells(y, "F")
ElseIf ws1.Cells(y, "E") = "13/02/2023" Then
ws3.Cells(x, "I").Value = ws3.Cells(x, "I").Value & " " & ws1.Cells(y, "F")
ElseIf ws1.Cells(y, "E") = "14/02/2023" Then
ws3.Cells(x, "J").Value = ws3.Cells(x, "J").Value & " " & ws1.Cells(y, "F")
End If
End If
Next y
Next x
Thank your for your assistance.
Bookmarks