Conditional Hiding of Rows in Excel

5 pts.
Tags:
conditional hiding rows
Excel VBA
Hiding rows
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
ASKED: April 8, 2010  6:45 AM
UPDATED: April 8, 2010  2:51 PM

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.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

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.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

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

Following