PDA

View Full Version : [SOLVED] Trouble with code to hide rows



paulked
06-11-2017, 06:50 AM
Hi there

I am using the code below to hide rows that aren't relevant to a combobox selection.



Private Sub ComboBox1_Change()
Dim lr As Long, x As Integer
lr = Cells(Rows.Count, 1).End(xlUp).Row
ActiveSheet.Cells.EntireRow.Hidden = False
If ComboBox1.Value = "Event" Then GoTo Xit
For x = 5 To lr
If Cells(x, 5).Value <> ComboBox1.Value Then Rows(x & ":" & x).EntireRow.Hidden = True
Next
Xit:
End Sub




The code only works correctly every other time, any idea what I'm doing wrong?

19465

Many thanks

YasserKhalil
06-11-2017, 07:45 AM
Hello
May be you should switch these two lines


ActiveSheet.Cells.EntireRow.Hidden = False
lr = Cells(Rows.Count, 1).End(xlUp).Row

mdmackillop
06-11-2017, 07:47 AM
Hi Paul

ActiveSheet.Cells.EntireRow.Hidden = False
lr = Cells(Rows.Count, 1).End(xlUp).Row


Edit: Too late :dunno

paulked
06-12-2017, 12:50 AM
Doh!

Thank you both :beerchug: