vba - Can't delete rows containing certain keyword within text -


i have written macro remove rows containing text in it. if either of keyword contains text, macro delete row. however, macro doesn't work @ all. perhaps, did wrong in it. hope me rectify this. in advance.

here i'm trying with:

sub customized_row_removal()     dim long     = 2     until cells(i, 1).value = ""         if cells(i, 1).value = "mth" or "rtd" or "npt"             cells(i, 1).select             selection.entirerow.delete         end if         = + 1     loop end sub 

the keyword within text searching in delete:

airline drive owner mth rtd repairs inc aana michael b et al abass oladokun abbott npt p airline aana mth abass repairs npt 

try this.
using lcase.

sub customized_row_removal()     dim rngdb range, rngu range, rng range     dim ws worksheet      set ws = sheets(1)     ws         set rngdb = .range("a2", .range("a" & rows.count))     end      each rng in rngdb         if instr(lcase(rng), "mth") or instr(lcase(rng), "rtd") or instr(lcase(rng), "npt")             if rngu nothing                 set rngu = rng             else                 set rngu = union(rngu, rng)             end if         end if     next rng     if rngu nothing     else         rngu.entirerow.delete     end if end sub 

Comments

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -