I have a little macro which searches through a sheet for cells highlighted yellow and then lists them on another sheet. Code is below
(RowCount is the line we're up to on the list, RowNumber is the row we're up to on the sheet we're searching and ColumnNumber is the column we're looking in)
The values in the yellow cells could be in the format "8:00", "08:00", "8:00 DB", "08:00DB" etc.
I want to split this into two values, one containing just the time part and one containing any following text.
Any ideas?
Thanks
Chris
Code:
PlaceHolder = InStr(Format(Sheets(WSheet.Name).Cells(RowNumber, ColumnNumber), "h:mm"), ":") + 2
If Len(Format(Sheets(WSheet.Name).Cells(RowNumber, ColumnNumber), "h:mm")) > PlaceHolder Then
Sheets("To Cover List").Cells(RowCount, 5) = Left(Format(Sheets(WSheet.Name).Cells(RowNumber, ColumnNumber), "hh:mm"), PlaceHolder)
Sheets("To Cover List").Cells(RowCount, 6) = Right(Format(Sheets(WSheet.Name).Cells(RowNumber, ColumnNumber), "hh:mm"), Len(Format(Sheets(WSheet.Name).Cells(RowNumber, ColumnNumber), "hh:mm") - PlaceHolder))
Else
Sheets("To Cover List").Cells(RowCount, 5) = Format(Sheets(WSheet.Name).Cells(RowNumber, ColumnNumber), "hh:mm")
End If
(RowCount is the line we're up to on the list, RowNumber is the row we're up to on the sheet we're searching and ColumnNumber is the column we're looking in)
The values in the yellow cells could be in the format "8:00", "08:00", "8:00 DB", "08:00DB" etc.
I want to split this into two values, one containing just the time part and one containing any following text.
Any ideas?
Thanks
Chris