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
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college

Forum statistics

Threads
1,213,521
Messages
6,114,109
Members
448,548
Latest member
harryls

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
Back
Top