I've added a line to replace the value in column 3.
VB Code:
Sub FindSolution() Dim MySheet As Worksheet Dim RowCount As Integer Dim SearchValue As String Dim MyRow As Integer Dim MyCell As Range Dim StartNum As Integer Set MySheet = Sheets("Sheet1") 'Set this variable to the worksheet that has your data RowCount = MySheet.UsedRange.Rows.Count 'Find how many rows are used on the sheet SearchValue = "Solution :" 'This is the value you are searching for For MyRow = MySheet.UsedRange.Row To MySheet.UsedRange.Row + RowCount - 1 'loop through each row in the used range Set MyCell = MySheet.Cells(MyRow, 3) 'set this variable to the cell in the third colum StartNum = InStr(1, MyCell, SearchValue, vbTextCompare) 'find the starting position of the search value in the searched cell If StartNum > 0 Then ' if the starting position is not zero then the value is in the cell MyCell.Offset(0, 2) = Mid(MyCell, StartNum) 'copy the text from the searched cell to the cell 2 columns to the right, starting with the search string MyCell = Application.WorksheetFunction.Replace(MyCell, StartNum, Len(MyCell.Offset(0, 2)), "") End If Next MyRow Set MyCell = Nothing 'clear your object variables Set MySheet = Nothing 'clear your object variables End Sub




Reply With Quote