Hiding a group of cells by condition

avinay

New Member
Joined
Feb 1, 2010
Messages
2
Hi.. I am an absolute newbie in this setting and would appreciate some help.
Is there a way by which you can hide a group of cells in an excel sheet by condition??

What I was trying to do was to
a) label rows according to date.
b) create a condition to hide the rows once the date has passed.

Please let me know if there is a method to do this. Thanks in advance.
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
Assume you have a range of dates from b2 to b10. Place this code in the sheets Code. It will activate only when the sheet is recalculated. right click on sheet tab and select "View code". PAste the following code in it. then try entering dates in range b2 to b10.

Code:
Private Sub Worksheet_Change(ByVal Target As Range)

   Dim myrange As Range
  Set myrange = Range("b2:b10")
   For Each cell In myrange
   If cell <> "" Then
   If cell.Value < Date Then
    cell.EntireRow.Hidden = True
    End If
    End If
    Next cell

End Sub
Nicole
 
Last edited:
Upvote 0
Thank you very much Nicole. I used the code and it works fine. thanks a lot for your help.
 
Upvote 0

Forum statistics

Threads
1,213,567
Messages
6,114,342
Members
448,570
Latest member
rik81h

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top