Hi there,
I am having some difficulty with concatenating dates & times in seperate columns on one worksheet into a single column on another sheet. My source data was created via html into .mht format, and opened with excel.
The time cells previously caused problems that I have been able to overcome with coding as times less than 10:00 were seen as numeric and times greater than 9:59 were seen as alpha.
The date cells seem fine & formatted as "dd/mm/yyyy" on the source sheet, but convert to "mm/dd/yyyy" when less than the 13th of the month, and are seen as alpha & formatted as dd/mm/yyyy when 13th or greater when output to the destination sheet.
I have tried as many variations in coding that I can with no success.
My current code reads :
Dim lTime As String
Dim lDate As Date
Dim lDateTime As String
'time
If IsNumeric(lrngC.Offset(0, 13).Value) Then
lTime = Format(lrngC.Offset(0, 13).Value, "hh:mm")
Else
lTime = Right(lrngC.Offset(0, 13).Value, 4)
End If
'date
If IsDate(lrngC.Offset(0, 10).Value) Then
lDate = lrngC.Offset(0, 10).Value
'Berth Date & time
lDateTime = lDate & " " & lTime
lrngD.Offset(0, 2).NumberFormat = lDateTime
End If
Any advice would be much appreciated
Nanette
I am having some difficulty with concatenating dates & times in seperate columns on one worksheet into a single column on another sheet. My source data was created via html into .mht format, and opened with excel.
The time cells previously caused problems that I have been able to overcome with coding as times less than 10:00 were seen as numeric and times greater than 9:59 were seen as alpha.
The date cells seem fine & formatted as "dd/mm/yyyy" on the source sheet, but convert to "mm/dd/yyyy" when less than the 13th of the month, and are seen as alpha & formatted as dd/mm/yyyy when 13th or greater when output to the destination sheet.
I have tried as many variations in coding that I can with no success.
My current code reads :
Dim lTime As String
Dim lDate As Date
Dim lDateTime As String
'time
If IsNumeric(lrngC.Offset(0, 13).Value) Then
lTime = Format(lrngC.Offset(0, 13).Value, "hh:mm")
Else
lTime = Right(lrngC.Offset(0, 13).Value, 4)
End If
'date
If IsDate(lrngC.Offset(0, 10).Value) Then
lDate = lrngC.Offset(0, 10).Value
'Berth Date & time
lDateTime = lDate & " " & lTime
lrngD.Offset(0, 2).NumberFormat = lDateTime
End If
Any advice would be much appreciated
Nanette