For Comparing two Excel columns in VBA, is it best to use Union, Intersect, or CountIf? -
i have 2 worksheets in excel. one, ("list") has list of 2000 or rows. other ("library") has large array of 2000 or columns, each 150 rows. want delete each column in "library" has nothing in appear in "list".
what have far (using countif function) is:
sub deletelibrary() dim rng range dim keyword range dim library worksheet dim list worksheet dim chunk range dim x long x = 1 application.screenupdating = true set library = sheets("library") set list = sheets("list") set keyword = list.range("a1:a2000") set chunk = library.range("a1:a150").offset(0, x) while x <= 1500 if application.worksheetfunction.countif(keyword, chunk) >= 1 x = x + 1 elseif application.worksheetfunction.countif(keyword, chunk) = 0 chunk.delete shift:=xlleft else: stop end if loop end end sub
however, gives me type mismatch first countif line. taking right approach? union or intersect better route?
thanks
Comments
Post a Comment