Hide Rows - Microsoft Community
                Office                /                        Excel                    /                        Windows 10                    /                        Office 365 for business                
 
  
i noticed on post, on how hide rows based on value, , added module can create button activate.
i keep getting syntax error on row says "if c.value = 1 then".
also, possible instead of looking hard value such 1, 2, 3, 4, can cell? instance, have column years in (2010, 2011, 2012, 2015, 2020, 2030). if wanted hide before current year, , have current year on cell a1 2017, cell a1, , hide other rows fall future year current year?
sub hide_e()
  dim lastrow long, c range
  application.enableevents = false
  lastrow = cells(cells.rows.count, "e").end(xlup).row
  on error resume next
  each c in range("e1:e" & lastrow)
     if c.value = 1 then
          c.entirerow.hidden = true
      elseif c.value = 2 then
          c.entirerow.hidden = false
      end if
  next
  on error goto 0
  application.enableevents = true
  end sub
thank you,
give try.
sub hide_e()
  dim lastrow long, c range
  application.enableevents = false
  lastrow = cells(cells.rows.count, "e").end(xlup).row
  on error resume next
  each c in range("e2:e" & lastrow)  'assumes header in col e
     if c.value > range("a1").value then
          c.entirerow.hidden = true
      elseif c.value <= range("a1").value then
          c.entirerow.hidden = false
      end if
  next
  on error goto 0
  application.enableevents = true
  end sub
gord
                Office                /                        Excel                    /                        Windows 10                    /                        Office 365 for business                
 
  
Comments
Post a Comment