Is there a faster way go compare two, unequal ranges in excel vba? -


this take forever execute. there faster way?

function add_column_binary(sheet_name_from string, col_from integer, sheet_to string, col_to integer)  '   set range  - range looped through find key searching second range     dim first_range range  '   set ragen - range in teh second sheet repeatedly searched     dim second_range range     set second_range = set_range(sheet_to, col_to)  '   find last column     dim last_col integer     last_col = worksheets(sheet_to).cells(1, columns.count).end(xltoleft).column  '   label last column     worksheets(sheet_to).cells(1, last_col + 1).value = "invited = 1"      dim rows1 long     rows1 = first_range.cells(rows.count, col_from).end(xlup).row + 1 ' grab length of range on first sheet      dim n long     dim constructed_id string      dim find_result range     n = 2 rows1         constructed_id = "objectid(" & first_range.cells(n, 1) & ")"  ' format object id         set find_result = second_range.find(constructed_id, lookin:=xlvalues, lookat:=xlwhole)         if not find_result nothing             worksheets(sheet_to).cells(n, last_col + 1) = "1"         else             worksheets(sheet_to).cells(n, last_col + 1) = "0"         end if     next n     stop  end function   sub test_stuff()      dim x range       set x = add_column_binary("invitesoutput.csv", 3, "usersfulloutput.csv", 1) '    debug.print "x = " & x.address end sub 

the first range on 8,000 cells , second range 15,000 cells.

it faster (between 10 , 100 times faster) data variant arrays , work on rather using find. see blog post https://fastexcel.wordpress.com/2011/10/26/match-vs-find-vs-variant-array-vba-performance-shootout/

if not fast enough @ using dictionaries etc: see https://fastexcel.wordpress.com/2012/07/10/comparing-two-lists-vba-udf-shootout-between-linear-search-binary-search-collection-and-dictionary/


Comments

Popular posts from this blog

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

java - Could not locate OpenAL library -

sorting - opencl Bitonic sort with 64 bits keys -