excel - Highlighting duplicate rows -


i highlight duplicate rows in excel vba. assume have following exemplary table columns a, b, c , d testing:

       b       c       d (strings)   1       1       1       dsf  2       3       5       dgdgdgdg  1       1       1       dsf  2       2       2       xxx  6       3       4       adsdadad  2       2       2       xxx 

the duplicate rows should highlighted in colour, e.g. grey. looking ideally fast performing code, used rather big tables. note there solutions available highlighting duplicate cells (but not duplicate rows). don't know how identify if rows duplicates , @ same time how fast, i.e. without nested looping. solution should in vba (not excel).

what best/fastest way achieve that?

i have tested 3 different approaches on sample file link op's comment. vba implementations not optimal, below results average time of 100 passes:

1) conditional formatting using:

a)sumproduct concatenating columns - 3s

b) countifs full column reference - 1.9s

c) countifs referencing used ranges - 0.2s

2) sorting range on columns, comparing row row, sorting - 0.3s

3) using advanced filter 3.5s

here code fastest method:

sub cf1()      application.screenupdating = false      dim sformula string     dim rrng range     dim ncol integer, integer      set rrng = range("a1").currentregion     ncol = rrng.columns.count      'build formula     sformula = "=countifs("      = 1 ncol       sformula = sformula & rrng.columns(i).address & "," & _          rrng.cells(1, i).address(false, true)       if < ncol sformula = sformula & ","     next     sformula = sformula & ")>1"      'write formula in helper cell it's local version     rrng.cells(1, ncol + 1).formula = sformula      rrng.formatconditions.delete     rrng.formatconditions.add(type:=xlexpression, _             formula1:=rrng.cells(1, ncol + 1).formulalocal)        .interior.themecolor = xlthemecoloraccent3     end      rrng.cells(1, ncol + 1).clear      application.screenupdating = true end sub 

Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -