Conditional hidding row

Closed
ben - Jul 5, 2011 at 02:29 AM
rizvisa1 Posts 4478 Registration date Thursday January 28, 2010 Status Contributor Last seen May 5, 2022 - Jul 6, 2011 at 08:11 AM
Hello,

I want to build a macro that hide some row related to the content of a cell.

In my sheet, I have a drop down list in M15, and regarding the choice in this ddlist, i want row to be hidden or not.

txs and rgds
Ben

Related:

1 response

rizvisa1 Posts 4478 Registration date Thursday January 28, 2010 Status Contributor Last seen May 5, 2022 766
Jul 5, 2011 at 06:48 AM
Not too sure how things are but have you looked at the using the change event of sheet by utilizing the routine


Private Sub Worksheet_Change(ByVal Target As Range)

End Sub
0
txs for your quick reply

Actually, I use these macro:

Sub Worksheet_Change(ByVal Target As Range)

If Target.Address = "$M$15" Then
If Target.Value = OTHE Then
Rows [62:72].EntireRow.hidden = True
Else
Rows [62:72].EntireRow.hidden = False
End If
End If
End Sub

but it reports a PopUp with: Argument not Optional

And there, I'm stuck ;-(((
0
rizvisa1 Posts 4478 Registration date Thursday January 28, 2010 Status Contributor Last seen May 5, 2022 766
Jul 5, 2011 at 08:10 AM
Well for me Rows [62:72] does not work. Rows("62:72") works for me. Other thing is that i am presuming that OTHE was a text and not a variable, so it needed to be enclosed in ". Based on the above two, the below code works for me

Sub Worksheet_Change(ByVal Target As Range)
   If Target.Address = "$M$15" _
   Then
      Rows("62:72").Hidden = (Target.Value = "OTHE")
   End If
End Sub
0
still same issue --> Argument not optional

really don't understand what happens ;-(
0
rizvisa1 Posts 4478 Registration date Thursday January 28, 2010 Status Contributor Last seen May 5, 2022 766
Jul 6, 2011 at 08:11 AM
Could you post a sample book with some sample data and your code on some shared site AND post back the link to the file back here.. May be it has to do with how sheet is there or some thing else.
0