excel - Remove duplicate values within dynamic ranges identified by text strings -


text “endofdata” in col b identifies boundaries of multiple ranges on single sheet. i’m trying step through each range , remove duplicate values in columns e , f within each range. call routine deletes blank rows generated when duplicates removed. bottom row “endofdata” removed when .removeduplicates executed.

i’ve tried loop it’s failing. (it works first range fails next range) please suggest how make work. kind of loop should use? how should search “endofdata” string? thank in advance.

enter image description here

sub removedupsinrange()   dim lastrow long, long, startrow, endrow  call setsheets  lastrow = wsqc.cells(wsqc.rows.count, "a").end(xlup).row  debug.print lastrow  = lastrow 1 step -1      if wsqc.cells(i, 2).value = "endofdata"           startrow =         end if     = - 1    loop until wsqc.cells(i, 2).value = "endofdata"    endrow =    = - 1     range(startrow & ":" & endrow).select    selection.removeduplicates columns:=array(5, 6), _         header:=xlno         call deleteblanks  next  end sub 

i tested loop , worked.

sub removedupsinrange()  dim lastrow long, long, rstart range, rend range  call setsheets  lastrow = wsqc.cells(wsqc.rows.count, "a").end(xlup).row  debug.print lastrow  set rend = wsqc.cells(lastrow, 2)  = lastrow 2 step -1               = - 1          if wsqc.cells(i, 2).value = "endofdata"             set rstart = wsqc.cells(i, 2)         end if       loop until wsqc.cells(i, 2).value = "endofdata"      wsqc.range(rstart.offset(, -1), rend.offset(, 4)).removeduplicates columns:=array(5, 6), header:=xlno      set rend = rstart      call deleteblanks  next  end sub 

Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -