I am working with the two pieces of code below. One hides rows when the sheet is activated and one hides columns when a combo box is updated. The error shows up when I activate the sheet, but when I debug, the error is referring to the combo box code and specifically the "Cells(1, indx).Columns.Hidden = DoHide" line.
Ideas?
Private Sub ComboBox10_Change()
Dim indx As Integer, DoHide As Boolean
Application.ScreenUpdating = False
ActiveSheet.DisplayPageBreaks = False
ActiveSheet.Protect DrawingObjects:=False, Contents:=False, Scenarios:=False
For indx = 2 To 200
DoHide = (Cells(1, indx) = 0) And (Cells(1, indx) <> "")
Cells(1, indx).Columns.Hidden = DoHide
Next indx
ActiveSheet.Protect DrawingObjects:=False, Contents:=False, Scenarios:=False
Application.ScreenUpdating = True
End Sub
Private Sub Worksheet_Activate()
Dim indx As Integer, DoHide As Boolean
Application.ScreenUpdating = False
ActiveSheet.DisplayPageBreaks = False
ActiveSheet.Protect DrawingObjects:=False, Contents:=False, Scenarios:=False
For indx = 2 To 200
DoHide = (Cells(indx, 1) = 0) And (Cells(indx, 1) <> "")
Cells(indx, 1).Rows.Hidden = DoHide
Next indx
ActiveSheet.Protect DrawingObjects:=False, Contents:=False, Scenarios:=False
Application.ScreenUpdating = True
End Sub
Bookmarks