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

symfony - InvalidConfigurationException in SecurityExtension.php line 429: No authentication listener registered for firewall "secured_area" -

angular ui router - 10 digest iterations reached in angularjs when using $state.go -

javascript - Handling constructor related functions while testing with mocha and sinon -