Search and delete row

S

Shawn

I have a table of data. I need a code that will search the column range
B3:B? (I don't know where the data will end). If there is a value in range
B3:B? that equals the value in B2, then I need that entire row deleted and
the rest of the data shifted up. Also, there may not be a value in B3:B?
equal to the value in B2. In that case, I need nothing to happen. Thank in
advance.
 
D

Don Guillett

sub deleterowifb2()
dim i as long
for i=cells(rows.count,"b").end(xlup).row to 3 step-1
if cells(i,"b")=cells(2,"b") then rows(i).delete
next i
end if
 
E

excelent

another way

Sub Terminator()
x = Cells(65000, 2).End(xlUp).Row
Range("B3:B" & x).Replace what:=Range("B2"), Replacement:="", _
lookat:=xlPart, SearchOrder:=xlByRows
Range("B3:B" & x).SpecialCells(xlCellTypeBlanks).Delete Shift:=xlUp
End Sub


"Don Guillett" skrev:
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top