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