I've reviewed many responses on this question, both on MrExcel and elsewhere, and just can't seem to get my hide-rows macro to run in Excel "LTSC":
I've tried a few syntax alternatives to the following "Case" method, but it just won't run (I did have it running in the module as a manual macro but not in the worksheet by a cell change). You will see two versions here, the second inactive one commented with leading '. (I've tried many different syntaxes). The range name TBOEx is a single cell j24 on sheet 2 (with a pulldown Yes,No validation). This is typical in my spreadsheet designs, to have a parameters page in which the user selects options, then a series of separate results pages. The rows I wish to hide when there is not data (Case "No") and to show in case "Yes", are on two other sheets, 12&13. i have a separate Case VBA Sub on this Sheet2 to hide and show complete worksheets and that one works fine from another pulldown cell. I've saved and reopened, rebooted, etc
I've tried a few syntax alternatives to the following "Case" method, but it just won't run (I did have it running in the module as a manual macro but not in the worksheet by a cell change). You will see two versions here, the second inactive one commented with leading '. (I've tried many different syntaxes). The range name TBOEx is a single cell j24 on sheet 2 (with a pulldown Yes,No validation). This is typical in my spreadsheet designs, to have a parameters page in which the user selects options, then a series of separate results pages. The rows I wish to hide when there is not data (Case "No") and to show in case "Yes", are on two other sheets, 12&13. i have a separate Case VBA Sub on this Sheet2 to hide and show complete worksheets and that one works fine from another pulldown cell. I've saved and reopened, rebooted, etc
VBA Code:
Private Sub HideRowsTBOEx(ByVal Target As Range)
'added below 2 lines per recommendation of several forums
TBOX = Worksheets("Sheet2").Range("TBOEx").Value
If Intersect(TBOX, Target) Is Nothing Then Exit Sub
Select Case TBOX
Case "No"
Worksheets("Sheet12").Rows("36:48").Hidden = True
Worksheets("Sheet3").Rows("36:48").Hidden = True
Case "Yes"
Worksheets("Sheet12").Rows("36:48").Hidden = False
Worksheets("Sheet3").Rows("36:48").Hidden = False
End Select
End Sub
'Inactive version
'Sub HideRows(ByVal Target As Range)
'macro did run using F5 in module but not here in sheet2 and not yet automatic on TBOEx change
'Select Case Sheet2.Range("j24").Value
'Case "No"
'Sheet12.Range("36:48").EntireRow.Hidden = True
'Sheet3.Range("36:48").EntireRow.Hidden = True
'Case "Yes"
'Sheet12.Range("36:48").EntireRow.Hidden = False
'Sheet3.Range("36:48").EntireRow.Hidden = False
' End Select
'End Sub
Last edited by a moderator: