Further to the solution in another workbook I was working on, Another VBA question to hide/unhide rows based on cell value in another sheet
I am now working on a very similar template for another product (turbine engine repair). Again, I am using a parameters page (Sheet 2 "Input Page") for users to select a variety of parameters to create several pricing sheets, and this Sub resides on Sheet2.
The Cell L4 test and loop is the same as in the prior solution, to show or hide (veryhide) sheets based on an input method of "Detail" vs "Summary" So I've just inserted that code into this Sub. Cell G9 is a requirement to veryhide two sheets for a particular engine model "B17F" but not for all other engine models. That code worked fine until the above insertion. As my VBA is based on decades old coding knowledge (FORTRAN), cobbling in answers from this board (and learning as I go), the second loop in this subroutine will no longer run.
The first loop runs fine for the most part, with L4 selection of Summary vs Detail except Sheet25 which is also in the 2nd loop. But changing G9 has no effect: Sheet21 stays hidden in all cases of G9 & L4, and Sheet25 stays visible in all cases. (PS, I did try changing the Case statement to If statement, no effect)
TIA
Gary (bertible)
I am now working on a very similar template for another product (turbine engine repair). Again, I am using a parameters page (Sheet 2 "Input Page") for users to select a variety of parameters to create several pricing sheets, and this Sub resides on Sheet2.
The Cell L4 test and loop is the same as in the prior solution, to show or hide (veryhide) sheets based on an input method of "Detail" vs "Summary" So I've just inserted that code into this Sub. Cell G9 is a requirement to veryhide two sheets for a particular engine model "B17F" but not for all other engine models. That code worked fine until the above insertion. As my VBA is based on decades old coding knowledge (FORTRAN), cobbling in answers from this board (and learning as I go), the second loop in this subroutine will no longer run.
Rich (BB code):
Private Sub Worksheet_Change(ByVal Target As Range)
'Application.Volatile
If Target.Cells.CountLarge = 1 And Not Intersect(Range("G9,L4"), Target) Is Nothing Then
On Error GoTo Escape
Application.EnableEvents = False
If Target.Address = "$L$4" Then
If Target = "Summary" Then
Sheet19.Visible = xlSheetVeryHidden
Sheet23.Visible = xlSheetVeryHidden
Sheet24.Visible = xlSheetVeryHidden
Sheet23.Visible = xlSheetVeryHidden
Sheet25.Visible = xlSheetVeryHidden
ElseIf Target = "Detail" Then
Sheet19.Visible = xlSheetVisible
Sheet23.Visible = xlSheetVisible
Sheet24.Visible = xlSheetVisible
Sheet23.Visible = xlSheetVisible
Sheet25.Visible = xlSheetVisible
End If
End If
End If
Continue:
Application.EnableEvents = True
Exit Sub
'Moved B17 Hide to after Detail Summary Sub Didn't work, Sheet 25 ends up visible whenever "Detail" case above
Select Case Sheet2.Range("G9").Value
Case "B17F"
Sheet21.Visible = xlSheetVisible
Sheet25.Visible = xlSheetVisible
Case Else
Sheet21.Visible = xlSheetVeryHidden
Sheet25.Visible = xlSheetVeryHidden
End Select
Escape:
MsgBox "Error " & Err.Number & ": " & Err.Description
Resume Continue
End Sub
The first loop runs fine for the most part, with L4 selection of Summary vs Detail except Sheet25 which is also in the 2nd loop. But changing G9 has no effect: Sheet21 stays hidden in all cases of G9 & L4, and Sheet25 stays visible in all cases. (PS, I did try changing the Case statement to If statement, no effect)
TIA
Gary (bertible)