Help with VB script to hide rows

TyeReece

Board Regular
Joined
Aug 3, 2007
Messages
136
I have an VB form with 5 combo or text boxes that hides rows in a sheet based on values in the form and columns in the worksheet (Gender, Age, IQ, level of care and on site school). It works fine if I only hide based on 1 of the combo/text boxes, but when I try to hide based on more than one, it unhides a row that is already hidden. How do I get the code to only hide the rows that meet the criteria and are visible when the code loops through? Below is part of the code and I imagine this is


Private Sub btnFiltered_Click()
SetSheetNames
If cboGender.Text = "Male" Then
FilterPrograms.HideMale = 0
FilterPrograms.HideFemale = 1
ElseIf cboGender.Text = "Female" Then
FilterPrograms.HideMale = 1
FilterPrograms.HideFemale = 0
ElseIf cboGender.Text = "" Then
FilterPrograms.HideMale = 0
FilterPrograms.HideFemale = 0
End If
If cboOnSiteSchool.Text = "Yes" Then
FilterPrograms.HideNoOnSiteSchool = 1
ElseIf cboOnSiteSchool.Text = "No" Then
FilterPrograms.HideNoOnSiteSchool = 0
ElseIf cboOnSiteSchool.Text = "" Then
FilterPrograms.HideNoOnSiteSchool = 0
End If
ShowHideSheets SheetNames.ComparisonTable
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
Me.Hide
End Sub



Thanks in advance
 

Some videos you may like

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.

Watch MrExcel Video

Forum statistics

Threads
1,122,335
Messages
5,595,573
Members
413,996
Latest member
mabelO

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top