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.
 

nicolewh

Well-known Member
Joined
Aug 7, 2009
Messages
554
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:

avinay

New Member
Joined
Feb 1, 2010
Messages
2
Thank you very much Nicole. I used the code and it works fine. thanks a lot for your help.
 

Forum statistics

Threads
1,081,800
Messages
5,361,382
Members
400,629
Latest member
ganeshkhatri

Some videos you may like

This Week's Hot Topics

  • populate from drop list with multiple tables
    Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
  • Find list of words from sheet2 in sheet1 before a comma and extract text vba
    Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
  • Dynamic Formula entry - VBA code sought
    Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...
  • Listbox Header
    Have a named range called "AccidentsHeader" Within my code I have: [CODE]Private Sub CommandButton1_Click() ListBox1.RowSource =...
  • Complex Heat Map using conditional formatting
    Good day excel world. I have a concern. Below link have a list of countries that carries each country unique data. [URL...
  • Conditional formatting
    Hi good morning, hope you can help me please, I have cells P4:P54 and if this cell is equal to 1 then i want row O to say "Fully Utilised" and to...
Top