String manipulation

ccordner

Active Member
Joined
Apr 28, 2010
Messages
355
I have a little macro which searches through a sheet for cells highlighted yellow and then lists them on another sheet. Code is below

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
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.

Forum statistics

Threads
1,224,586
Messages
6,179,718
Members
452,939
Latest member
WCrawford

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top