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

mysql - FireDac error 314 - but DLLs are in program directory -

git - How to list all releases of public repository with GitHub API V3 -

c++ - Getting C2512 "no default constructor" for `ClassA` error on the first parentheses of constructor for `ClassB`? -