使用我设置的这段代码,我正在使用过滤器,它与带有复选框的用户表单相关联,以选择要过滤的内容。目前,如果我过滤一个变量,如实用程序它过滤器,但如果我移动到另一个过滤器说客户端,然后我过滤而不是给我与先前过滤的特定实用程序关联的客户端,它会清除所有内容并仅过滤客户端。
我认为解决方案可能必须处理方法:.SpecialCells(xlCellTypeVisible)
Private Sub Cancel_UF_Click()
UtilityFilter.Hide
Range("A1").Select
End Sub
Private Sub Confirm_UF_Click()
ActiveSheet.Unprotect ("UMC626")
ClearFilter
UpdateFilters
UtilityFilter.Hide
Application.ScreenUpdating = False
Range("A1").Select
ActiveSheet.Protect Password:="UMC626", _
DrawingObjects:=False, _
Contents:=True, _
Scenarios:=True
End Sub
Sub SelectAll_UF_Click()
If SelectAll = True Then
Electricty_UF.Value = True
Gas_UF.Value = True
NonUtility_UF.Value = True
SolarElectricity_UF.Value = True
SolarThermal_UF.Value = True
SolidWaste_UF.Value = True
Water_UF.Value = True
Else
Electricity_UF.Value = False
Gas_UF.Value = False
NonUtility_UF.Value = False
SolarElectricity_UF.Value = False
SolarThermal_UF.Value = False
SolidWaste_UF.Value = False
Water_UF.Value = False
End If
End Sub
Sub UpdateFilters()
Integer_UF = -1
If Electricity_UF.Value = True Then
Add_UF String_UF, "E"
Range("E6:E67").AutoFilter Field:=1, _
Criteria1:=String_UF, _
Operator:=xlFilterValues
End If
If Gas_UF.Value = True Then
Add_UF String_UF, "G"
Range("E6:E67").AutoFilter Field:=1, _
Criteria1:=String_UF, _
Operator:=xlFilterValues
End If
If NonUtility_UF.Value = True Then
Add_UF String_UF, "NU"
Range("E6:E67").AutoFilter Field:=1, _
Criteria1:=String_UF, _
Operator:=xlFilterValues
End If
If SolarElectricity_UF.Value = True Then
Add_UF String_UF, "SE"
Range("E6:E67").AutoFilter Field:=1, _
Criteria1:=String_UF, _
Operator:=xlFilterValues
End If
If SolarElectricity_UF.Value = True Then
Add_UF String_UF, "SE"
Range("E6:E67").AutoFilter Field:=1, _
Criteria1:=String_UF, _
Operator:=xlFilterValues
End If
If SolarThermal_UF.Value = True Then
Add_UF String_UF, "ST"
Range("E6:E67").AutoFilter Field:=1, _
Criteria1:=String_UF, _
Operator:=xlFilterValues
End If
If SolidWaste_UF.Value = True Then
Add_UF String_UF, "SW"
Range("E6:E67").AutoFilter Field:=1, _
Criteria1:=String_UF, _
Operator:=xlFilterValues
End If
If Water_UF.Value = True Then
Add_UF String_UF, "W"
Range("E6:E67").AutoFilter Field:=1, _
Criteria1:=String_UF, _
Operator:=xlFilterValues
End If
End Sub
Sub Add_UF(String_UF() As String, NewValue As String)
Integer_UF = Integer_UF + 1
ReDim Preserve String_UF(Integer_UF)
String_UF(Integer_UF) = NewValue
End Sub
我认为重点应该放在 Add_UF 我称之为 NewValue。是否有在排序后对列进行排序?正如您在下图中看到的那样,我希望能够对一列进行排序。在能源上说,然后在工作类型上进行排序。