Private Sub CancelUtility_Click()
UtilityFilter.Hide
End Sub
Private Sub SelectElectricity_Click()
If SelectElectricity = False Then
End Sub
Private Sub SelectGas_Click()
End Sub
Private Sub SelectSolarElectricity_Click()
End Sub
Private Sub SelectSolarThermal_Click()
End Sub
Private Sub SelectSolidWaste_Click()
End Sub
Private Sub SelectWater_Click()
End Sub
Private Sub UtilityFilterText_Click()
End Sub
我要做的是设置一个弹出框以便作为过滤器使用。如果未选中复选框,我希望它根据每个实用程序值隐藏每一行。
E =电力
G =气体
SE =太阳能电力
ST =太阳能热
SW =固体废物
W =水
目前我在启动以下宏时打开了一个弹出窗口。
Sub UtilityPopup()
UtilityFilter.Show
End Sub
Popup是我创建的一个名为“UtilityFilter”的自定义用户形式
感谢您的帮助!
答案 0 :(得分:1)
创建一个更新过滤器的函数,并从您已有的所有事件函数中调用它。类似的东西:
Private Filters() As String
Private NFilters As Integer
Private Sub UtilityFilterText_Click()
UpdateFilters
End Sub
Private Sub SelectWater_Click()
UpdateFilters
End Sub
Private Sub UpdateFilters()
NFilters = -1
If CheckboxSelectWater.Value Then AddFilter Filters, "W"
If CheckboxElectricity.Value Then AddFilter Filters, "E"
Range("A1:F10").AutoFilter Field:=1, Criteria1:=Filters, Operator:=xlFilterValues
End Sub
Private Sub AddFilter(Filters() As String, NewValue As String)
NFilters = NFilters + 1
ReDim Preserve Filters(NFilters)
Filters(NFilters) = NewValue
End Sub
Here您可以找到Range.AutoFilter
方法的文档。