显示某些行,但保持其他人隐藏

我正在使用Excel工作簿,在其中一个工作表上是隐藏或显示的行,这取决于在另一个工作表中select的选项。 结构看起来像这样

A 1 2 3 4 B 1 2 3 4 C 1 2 3 4 

他们可以select隐藏A和B,A和C,A,B或C的所有选项。用户可以隐藏A和B或C(他们必须在B或C之间select)。他们也有选项隐藏每个字母下的单个行。 行1,2和3.如果隐藏选项2被选中,每个字母下的所有“2”行都被隐藏。 如果他们没有选中这个选项,所有2行再次出现。 问题是显示已经隐藏的字母的“2”行。

我遇到了一个心理障碍,但这是我所做的。 Psuedocode的可读性,因为现在我的代码是凌乱的,我恨vba的样子。 无论如何,这是一个逻辑问题而不是语法问题。

 Property hiddenA As Bool get let Property hiddenB As Bool get let Property hiddenC As Bool get let OptionButton1.Click() hiddenA = true Hide A row and all rows associated with it OptionButton2.Click() HiddenA = false Show A row and all rows associated with it OptionButton3.Click() HiddenB = false HiddenC = true Show B row and all rows associated with it Hide C row and all rows associated with it OptionButton4.Click() HiddenB = true HiddenC = false Hide B row and all rows associated with it Show A row and all rows associated with it CheckBox1.Click() if CheckBox1.value = false Then Hide all "1" rows Else Show all "1" rows, but keep the "1"s under already hidden letters, hidden. This is the problem. 

等等。 还有显示/隐藏所有2,3和4行的checkbox。

粗略的轮廓 – 未经testing的代码…这样的事情应该取消隐藏一切,检查每个checkbox的状态,添加checkbox到范围,并隐藏整个范围结束。

 'CheckBox1 is Row 1 in group 'CheckBox2 is Row 2 in group 'CheckBox3 is Row 3 in group 'CheckBox4 is Row 4 in group 'CheckBox5 is Row 5 in group 'CheckBox6 is Group A 'CheckBox7 is Group B 'CheckBox8 is Group C 'CheckBox9 is Group D 'CheckBox10 is Group E Sub CheckBoxClick() 'Assign this to all checkboxes Application.ScreenUpdating = False 'Turn off screen updating ActiveSheet.Cells.EntireRow.Hidden = False 'Unhide all Dim RngCnt As Range Dim LastRow As Long Dim CurRow As Long Dim ChkBx As OLEObject LastRow = Range("A" & Rows.Count).End(xlUp).Row For Each ChkBx In ActiveSheet.OLEObjects If TypeName(ChkBx.Object) = "CheckBox" Then Select Case ChkBx.Name Case "CheckBox1" If ChkBx.Value = True Then RngCnt = Union(RngCnt, Range(Rows this chk box effects)) End If Case "CheckBox2" If ChkBx.Value = True Then RngCnt = Union(RngCnt, Range(Rows this chk box effects)) End If Case ETC, ETC, ETC to "CheckBox10" ... End If Next ChkBx RngCnt.EntireRow.Hidden = True Application.ScreenUpdating = True End Sub