Conditional Hiding of Rows in Excel

5 pts.
Tags:
Excel VBA
Hi, I work on some projects and I maintain status of those in an excel file in column L. The status of the projects varies as I wrok (Stages). The final status of the project is named as "Completed". Now I want the whole row to get hide when I select the status "Completed" from the list. Eg. If I select L2 value be completed. Complete Row (ie., 2) shud get hidden. I have a macro which I find on the internet & I amended it a little bit for my needs with my very little VBA knowledge. But this is working only for 1st row. Below is what I have.

Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Range("L1").Value = "Completed" Then Rows("1").EntireRow.Hidden = True Else Rows("1").EntireRow.Hidden = False End If End Sub

Appreciate your help. Thanks in advance, Khazi



Software/Hardware used:
Excel 2003

Answer Wiki

Thanks. We'll let you know when a new response is added.

I modified your code to use the Change event instead of the SelectionChange event, and use the Range parameter to hide the modified row.

I think this should work:

<pre>Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Value = “Completed” Then
Target.EntireRow.Hidden = True
Else
Target.EntireRow.Hidden = False
End If
End Sub</pre>

-CarlosDL

————

Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.

Following

Share this item with your network: