excel - macro to delete all the rows containing specific values -
this question has answer here:
i have been working on code delete rows if there specific value in cells column a. works fine , delete rows need, loop keeps going , not understand should stop @ cell "a400". me? thank you!
sub apaga1() dim pulo string sheets("sistema").activate cells.find("lf00").activate activecell.offset(1, 0).select lastcell = range("a400") 'apagar lfs until x = coelhoviado if left(activecell, 3) = "lf " or left(activecell, 3) = "lfs" or left(activecell, 4) = "lf00" or left(activecell, 3) = "lft" activecell.entirerow.delete shift:=xlup activecell.offset(-1, 0).select x = x + 1 end if activecell.offset(1, 0).select loop end sub
try code:
sub test() dim lastcell long dim long dim ws worksheet dim rng range set ws = sheets("sistema") lastcell = 400 = lastcell 1 step -1 set rng = ws.range("a" & i) if left(rng.value, 3) = "lf " or left(rng.value, 3) = "lfs" or _ left(rng.value, 4) = "lf00" or left(rng.value, 3) = "lft" rng.entirerow.delete shift:=xlup end if next end sub
Comments
Post a Comment