Hiding Rows that do not Have Values VBA -
i'm trying write macro goes through list , hides row if there no values in of columns of row. however, data has hidden columns macro. here's attempt below, doesn't seem of yet. appreciated.
sub hiderowsmenu() beginrow = 5 'start after master menu item endrow = 731 'filter rows in sheet (about 730) columnswithvalues = 0 'counter number of columns in row have value. if 0, hide row. columnstart = 2 'start have group values columnend = 50 'maximum number of groups rownumber = 0 columnnumber = 0 'outer loop cycles through rows of range, inner cycles through columns check values rownumber = beginrow endrow columnswithvalues = 0 'reset counter 0 avoid counting last row's values columnnumber = columnstart columnend 'if given cell index empty (0) , cell not hidden, add 1 counter if cells(rownumber, columnnumber).value = 0 , cells(rownumber, columnnumber).columns.hidden = false columnswithvalues = columnswithvalues + 1 end if next columnnumber 'after going through columns of row, check if there column values. if not, hide row if columnswithvalues = 0 cells(rownumber, columnnumber).entirerow.hidden = true end if 'repeat rows next rownumber end sub
would not work? (untested)
'## declare range variable represent current row' dim rowrange range rownumber = beginrow endrow '# set range variable, visible cells' set rowrange = range(cells(rownumber, columnstart), cells(rownumber, columnend)).specialcells(xlcelltypevisible) '# use magic determine if there values in row if application.worksheetfunction.counta(rowrange) = 0 rowrange.entirerow.hidden = true end if next rownumber
Comments
Post a Comment