excel - VBA script to compare 2 sheets and delete duplicated cells “Big Search Range” -


i want script compare "sheet 1 cells" "sheet 2 cells" , delete duplicates sheet 2. using script

option explicit sub cleandupes() dim targetarray, searcharray dim targetrange range dim x long  'update these 4 lines if target , search ranges change dim targetsheetname string: targetsheetname = "sheet2" dim targetsheetcolumn string: targetsheetcolumn = "a" dim searchsheetname string: searchsheetname = "sheet1" dim searchsheetcolumn string: searchsheetcolumn = "a"  'load target array sheets(targetsheetname)     set targetrange = .range(.range(targetsheetcolumn & "1"), _             .range(targetsheetcolumn & rows.count).end(xlup))     targetarray = targetrange end 'load search array sheets(searchsheetname)     searcharray = .range(.range(searchsheetcolumn & "1"), _             .range(searchsheetcolumn & rows.count).end(xlup)) end   dim dict object set dict = createobject("scripting.dictionary") dict.comparemode = 0 if isarray(searcharray)     x = 1 ubound(searcharray)         if not dict.exists(searcharray(x, 1))             dict.add searcharray(x, 1), 1         end if     next else     if not dict.exists(searcharray)         dict.add searcharray, 1     end if end if  'delete rows values found in dictionary if isarray(targetarray)     'step backwards avoid deleting wrong rows.     x = ubound(targetarray) 1 step -1         if dict.exists(targetarray(x, 1))             targetrange.cells(x).entirerow.delete         end if     next else     if dict.exists(targetarray)         targetrange.entirerow.delete     end if end if end sub 

but facing problem search range, excel limits sheet rows around 1 million, every month search range increased 300k row, can't use script. asking method play around limitation.

notes: -- target range placed in sheet 2, column , not exceed limitation. -- script should case sensitive. (ccse3e, ccse3e aren't duplicates)

if need more 1 million rows, can suggest consider moving database solution. excel won't scale.


Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -