Forum Discussion
Marieke1405
Feb 23, 2022Copper Contributor
VBA to hide rows based on value in cell (multiple criteria)
Hello all, I've made a summary sheet of a questionnaire in a workbook. Not all questions have to be answered, and I'm trying to make a macro that would automatically hide rows of the questions th...
HansVogelaar
Feb 23, 2022MVP
Right-click the sheet tab.
Select 'View Code' from the context menu.
Copy the following code into the worksheet module:
Private Sub Worksheet_Activate()
Intersect(Range("C:C"), Me.UsedRange).AutoFilter Field:=1, Criteria1:="<>"
End Sub
Switch back to Excel.
Save the workbook as a macro-enabled workbook (*.xlsm).
Make sure that you allow macros when you open it.
The filter will be updated automatically when you activate the Resumen sheet.
Marieke1405
Mar 09, 2022Copper Contributor
Thanks very much! Apologies for the late reply, I've tried the code but it doesn't seem to be working. Not sure what the problem could be, but it's not executing.
- HansVogelaarMar 09, 2022MVP
Try the attached version. I also added a Workbook_Open event procedure to the ThisWorkbook module.
Since it is now a macro-enabled workbook (.xlsm), you'll have to allow macros when you open it.