Forum Discussion
chanyuhui :
Apr 26, 2018Copper Contributor
Excel - automatically hiding select rows based on drop down selection
Hi there! I have a drop down selection of 10 items on my dashboard tab and am trying to only show rows 57 to 72 when I select one of them. I am using the following code but somehow it is not working...
Haytham Amairah
Jan 12, 2020Silver Contributor
Yes, that's possible!
Try this code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Range("B3") = "1" Then
Rows("10:15").EntireRow.Hidden = False
ActiveSheet.PageSetup.PrintArea = "$A$1:$H$15"
Else
Rows("10:15").EntireRow.Hidden = True
ActiveSheet.PageSetup.PrintArea = "$A$1:$H$9"
End If
End Sub
wmsawchuk
Jan 12, 2020Copper Contributor
Thank you very much for the code to set the print area. It works great and I really appreciate your help.
- NikolinoDEJul 13, 2020Gold Contributormaybe the other way round...
ALT + F11 and click on the desired picture, copy the code ... change the lines as desired beforehand.
Private Sub Worksheet_Change(ByVal Target As Range)
Dim Bereich As Range, Berechnung As Long
Berechnung = Application.Calculation
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = False
Me.Unprotect ("1234")
Set Bereich = Intersect(Target, Range("A15:A1009"))
If Not Bereich Is Nothing Then
Application.EnableEvents = False
Range("A15:A1009").EntireRow.Hidden = False
Range("A10:A1000").EntireRow.AutoFit
Range("A" & 45 + WorksheetFunction.CountA( _
Range("A15:A1009")) & ":A1009").EntireRow.Hidden = True
End If
Me.Protect ("1234")
Application.EnableEvents = True
Application.Calculation = Berechnung
Application.ScreenUpdating = True
End Sub
Regards,
Nikolino
(Knows I don't know anything)- NikolinoDEJul 13, 2020Gold Contributordesired picture = disired sheet