excel - Ignore empty cells in for each VBA -


i having problem loop(i go throu columns in every worksheet , copy them common column ) in vba. , wan't ignore empty cells... ideas? bellow code

application.screenupdating = false lastrowmaster = 1  each ws in sheets(array("1l", "5l"))          lastrow = ws.range("a" & rows.count).end(xlup).row         ws.range("a1:a" & lastrow).copy destination:=worksheets("podatki plana").range("a" & lastrowmaster)         lastrowmaster = worksheets("podatki plana").range("a" & rows.count).end(xlup).row + 1  next  application.screenupdating = true msgbox "done!" 

i altered line of code:

ws.range("a1:a" & lastrow).copy destination:=worksheets("podatki plana").range("a" & lastrowmaster) 

to this:

ws.range("a1:a" & lastrow).specialcells(xlcelltypeconstants).copy destination:=worksheets("podatki plana").range("a" & lastrowmaster) 

using .specialcells(xlcelltypeconstants) qualifier selects cells have value in them. change xlcelltypeconstants xlcelltypeformulas or of options listed on this msdn article.

the benefit don't have loop through each cell, solution comes performance penalty.

tested in excel 2013.


Comments

Popular posts from this blog

html - Firefox flex bug applied to buttons? -

html - Missing border-right in select on Firefox -

python - build a suggestions list using fuzzywuzzy -