Ok, I have been going insane here trying to figure out a code. I'm fairly new to VBA, but not programming in general. Here's my dilemma:
I have ~3000 rows of text in column B. I need to search within each cell in column B for a word. However, the cell will have multiple words in it, but I only want to look for one (so regularly I would use the INSTR function).
Then, if the word is found within the cell, I need to copy the whole row to another sheet. If it doesn't exist, exit sub for all I care.
So far I have (but it doesn't work):
Sub Contain_Copy()
Dim ranger As Long
Dim lastrow As Long
lastrow = Range("B3741").End(xlUp).Row
Sheets("Extract").Select
For ranger = 2 To lastrow
If InStr(1, Range("B" & ranger), "SWR", vbTextCompare) Then Range("B" & ranger).EntireRow.Copy _
Destination:=Sheets("Sheet6").Range("A1").End(xlUp).Offset(1, 0)
Next ranger
End Sub
Could someone pleeeease take a look at this and help me out before I go mad?
I have ~3000 rows of text in column B. I need to search within each cell in column B for a word. However, the cell will have multiple words in it, but I only want to look for one (so regularly I would use the INSTR function).
Then, if the word is found within the cell, I need to copy the whole row to another sheet. If it doesn't exist, exit sub for all I care.
So far I have (but it doesn't work):
Sub Contain_Copy()
Dim ranger As Long
Dim lastrow As Long
lastrow = Range("B3741").End(xlUp).Row
Sheets("Extract").Select
For ranger = 2 To lastrow
If InStr(1, Range("B" & ranger), "SWR", vbTextCompare) Then Range("B" & ranger).EntireRow.Copy _
Destination:=Sheets("Sheet6").Range("A1").End(xlUp).Offset(1, 0)
Next ranger
End Sub
Could someone pleeeease take a look at this and help me out before I go mad?