• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

VBA to hide the row based on the selection in the dropdown.

abdulncr

Member
Hi,


I want to Hide or Show rows based on criteria.


I have a drop down selection in D4 in the sheet jimmy that allows to select date Dec-12 to Dec-16 (mmm-yy) This list corresponds with values in column in the range b9:b500 in the same sheet. I want to hide every row except for those where D4 matches the value in column B. can any one advice a VBA code for this.


Thanks in advance


Abdul.
 
Abdul


Copy the following code to the Jimmy Worksheet module:

[pre]
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim c As Range

If Target.Address <> "$D$4" Then Exit Sub

For Each c In Range("B9:B500")
c.EntireRow.Hidden = False
If c.Value <> [D4] Then c.EntireRow.Hidden = True
Next c

End Sub
[/pre]
 
Back
Top