Hiding Cells in Excel with a macro -


i desperatly looking excel macro hide rows if criteria met. have tried enter code provided in other question answers , cannot damn thing run.

my code below runs wonderfully without row hidden part

i need following calc before template generated

if range f30 j30 blank rows 29 30 must hidden if range f33 j33 blank rows 32 33 must hidden if range f30 j33 blank rows 28 35 must hidden 

can please assist me

function rangename(sname string) string rangename = application.substitute(sname, " ", "_") end function sub mergeprint() dim wsform worksheet, wsdata worksheet dim srngname string, r long, c integer set wsform = worksheets("template") set wsdata = worksheets("datasource") wsdata.cells(1, 1).currentregion r = 2 .rows.count if not wsdata.cells(r, 1).entirerow.hidden c = 1 .columns.count srngname = wsdata.cells(1, c).value range(rangename(srngname)).value = wsdata.cells(r, c) next wsform.printout end if next end end sub 

you use formulas mark row hiding, use specialcells return rows need hidden , set hidden property true or false.

in column (for example, column n) add formula:

=if(len(concatenate(f:f,g:g,h:h,i:i,j:j))=0,na(),"")

you can put formula in programmatically using vba:
range("n28:n35").formula = "=if(len(concatenate(f:f,g:g,h:h,i:i,j:j))=0,na(),"""")"

this check cells, , return #n/a error if blank.

now can use specialcells function in vba select rows hidden:

cells.specialcells(xlcelltypeformulas, xlerrors).entirerow.hidden = true


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

java - Using an Integer ArrayList in Android -