select nonblank cells, filter, and copy and paste excel vba -


just title says i'm trying select cells not blank in first column select whole selection. macro loops through , counts rows int column until not blank find selection. filter. remove duplicates. copy , paste new sheet. i'm getting debug error , wondering if me out code. have:

sub sum()  dim countrow integer  countrow = 2  until isempty(cells(countrow, 1))     countrow = countrow + 1 loop  selection.autofilter activecell.select activesheet.range(cells(1, 1), cells(7, countrow)).autofilter field:=4, criteria1:="=yes*", _ operator:=xland countrow = 2  until isempty(cells(countrow, 1))     countrow = countrow + 1 loop  selection.autofilter activecell.select activesheet.range(cells(1, 1), cells(7, countrow)).select  selection.copy sheets.add after:=sheets(sheets.count) activesheet.paste application.cutcopymode = false activesheet.range(cells(1, 1), cells(7, countrow)).removeduplicates columns:=array(1, 7), _     header:=xlyes end sub 

activesheet.range(cells(1, 1), cells(7, countrow)).select 

should

activesheet.range(cells(1, 1), cells(countrow, 7)).select 

Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -