Wednesday 15 January 2014

Excel VBA: filter list for "empty" (failed matching) values then copy and paste to new column Code loop -



Excel VBA: filter list for "empty" (failed matching) values then copy and paste to new column Code loop -

i'm new excel vba im trying compared 2 lists mutual values. there cells appear empty contain " " result of no match. trying loop through list , re-create values not " " new column. reason excel keeps looping without code ever finishing unless stop it.

sub order() dim x long x = 2 activesheet.cells(x, 10).select while x < 19112 , activecell.value <> " " activesheet.cells(x, 10).select activecell.copy activesheet.cells(x, 11).select activesheet.pastespecial wend x = x + 1 end sub

now, before analysing below code please have how avoid using .select in excel vba macros

instead of looping rather slow may want seek faster solution using autofilter

sub betterone() dim lastrow long lastrow = range("j" & rows.count).end(xlup).row dim columnj range set columnj = range("j1:j" & lastrow) columnj.autofilter columnj.autofilter field:=1, criteria1:="<>" columnj.copy range("k1").pastespecial paste:=xlpastevalues application.cutcopymode = false columnj.autofilter end sub

excel list vba loops filter

No comments:

Post a Comment