excel - must remove first character of cell if not #3Created loop never ends -
so basically, need remove records don't have 3 2nd digit in primary key field example can either this
#39001
or without #3
what want cells have non #3 start, rows deleted came following code, removes all, macro never stops running..
sub keep3() ' ' removenum macro dim integer = 2 while < 14000 if instr(cells(i, 2), "3") = 2 ' nothing = + 1 else rows(i).entirerow.delete ' note - not incrementing here end if wend end sub
any ideas?
thanks
try instead:
sub keep3() dim integer = 14000 2 step -1 if mid(cells(i, 2), 2, 1) = "3" rows(i).entirerow.delete end if next end sub
note loop going backwards - because when delete row, row below gets pulled up, loop can strange things if go forwards , delete row, may skip on next row may have wanted delete. also, changed if statement said want delete rows 2nd character 3.
Comments
Post a Comment