大家,早安,
我有一个要对数据进行排序的宏。我的工作簿中的一个按钮调用一个带有 10 个复选框的小用户窗体。用户应该选择他想要查看的类别并单击排序。我想要的结果仅适用于他选择显示的类别,但我从附加的宏中得到了全有或全无的结果。下面是支持表单/按钮对类别进行排序的宏。我搜索了谷歌和其他几个论坛,但找不到与我的问题相关的答案!您能提供的任何帮助将不胜感激。
谢谢!
Private Sub cmdSort_Click()
LastRow = Range("A" & Rows.Count).End(xlUp).Row
If chkFE = True Then
For Each cell In Range("BC4:BC" & LastRow)
If UCase(cell.Value) <> "Fire Extinguishers" Then
cell.EntireRow.Hidden = True
End If
Next
End If
If chkChem = True Then
For Each cell In Range("BD4:BD" & LastRow)
If UCase(cell.Value) <> "Chem" Then
cell.EntireRow.Hidden = True
End If
Next
End If
If chkFL = True Then
For Each cell In Range("BE4:BE" & LastRow)
If UCase(cell.Value) <> "FL" Then
cell.EntireRow.Hidden = True
End If
Next
End If
If chkElec = True Then
For Each cell In Range("BF4:BF" & LastRow)
If UCase(cell.Value) <> "Elec" Then
cell.EntireRow.Hidden = True
End If
Next
End If
If chkFP = True Then
For Each cell In Range("BG4:BG" & LastRow)
If UCase(cell.Value) <> "FP" Then
cell.EntireRow.Hidden = True
End If
Next
End If
If chkLift = True Then
For Each cell In Range("BH4:BH" & LastRow)
If UCase(cell.Value) <> "Lift" Then
cell.EntireRow.Hidden = True
End If
Next
End If
If chkPPE = True Then
For Each cell In Range("BI4:BI" & LastRow)
If UCase(cell.Value) <> "PPE" Then
cell.EntireRow.Hidden = True
End If
Next
End If
If chkPS = True Then
For Each cell In Range("BJ4:BJ" & LastRow)
If UCase(cell.Value) <> "PS" Then
cell.EntireRow.Hidden = True
End If
Next
End If
If chkSTF = True Then
For Each cell In Range("BK4:BK" & LastRow)
If UCase(cell.Value) <> "STF" Then
cell.EntireRow.Hidden = True
End If
Next
End If
If chkErgonomics = True Then
For Each cell In Range("BL4:BL" & LastRow)
If UCase(cell.Value) <> "Ergonomics" Then
cell.EntireRow.Hidden = True
End If
Next
End If
Unload frmSort
End Sub