J
jsd219
Hi all,
Below is a sample of a cell:
Families with pets CHAPTER 1
I need to locate this cell, by searching for the "CHAPTER" text,
extract everything but CHAPTER 1, paste it in the cell adjacent to it,
leaving the original cell with "CHAPTER 1" only and "Families with
pets" will be in the next cell over, then color the entire row.
Here is what i have so far: from here i am at a loss. any help would be
much appreciated
Sub FindMoveColor()
Dim rng As Range
Dim cell As Range
Dim start_str As Integer
myword = InputBox("Enter the search string ")
Mylen = Len(myword)
With Worksheets(InputBox("Enter the Worksheet"))
Set rng = .Range("N1", .Cells(.Rows.Count, "N").End(xlUp))
End With
For Each cell In rng
start_str = InStr(cell.Value, myword)
If start_str Then
cell.EntireRow.Interior.Color = RGB(204, 255, 204)
cell.Copy
cell.Offset(0, 1).PasteSpecial
cell.Offset(0, 0).Value = myword
cell.Offset(0, 1).Characters(start_str, Mylen).Delete
End If
Next
End Sub
God bless
jsd219
Below is a sample of a cell:
Families with pets CHAPTER 1
I need to locate this cell, by searching for the "CHAPTER" text,
extract everything but CHAPTER 1, paste it in the cell adjacent to it,
leaving the original cell with "CHAPTER 1" only and "Families with
pets" will be in the next cell over, then color the entire row.
Here is what i have so far: from here i am at a loss. any help would be
much appreciated
Sub FindMoveColor()
Dim rng As Range
Dim cell As Range
Dim start_str As Integer
myword = InputBox("Enter the search string ")
Mylen = Len(myword)
With Worksheets(InputBox("Enter the Worksheet"))
Set rng = .Range("N1", .Cells(.Rows.Count, "N").End(xlUp))
End With
For Each cell In rng
start_str = InStr(cell.Value, myword)
If start_str Then
cell.EntireRow.Interior.Color = RGB(204, 255, 204)
cell.Copy
cell.Offset(0, 1).PasteSpecial
cell.Offset(0, 0).Value = myword
cell.Offset(0, 1).Characters(start_str, Mylen).Delete
End If
Next
End Sub
God bless
jsd219