Excel中用VBA函數進行顏色篩選的操作方法
在excel中,使用可視化的簡單操作方法,是很難根據顏色來篩選的,因此,我們只能使用VBA代碼來實現。今天,學習啦小編就教大家在Excel中用VBA函數進行顏色篩選的操作技巧。
Excel中用VBA函數進行顏色篩選的操作步驟:
以下代碼的功能是:除首行外,將當前單元格所在列數據與當前單元格不同顏色的行隱藏起來,數據首行為標題列。
如果你有其它的需求,請自行修改代碼。
Sub FilterColor()
Dim UseRow, AC
UseRow = Cells.SpecialCells(xlCellTypeLastCell).Row
If ActiveCell.Row > UseRow Then
MsgBox "超出范圍,請選擇有數據或有意思的單元格!", vbExclamation, "錯誤"
Else
AC = ActiveCell.Column
Cells.EntireRow.Hidden = False
For i = 2 To UseRow
If Cells(i, AC).Interior.ColorIndex <> ActiveCell.Interior.ColorIndex Then
Cells(i, AC).EntireRow.Hidden = True
End If
Next
End If
End Sub
Excel中用VBA函數進行顏色篩選的操作方法相關文章:
Excel中用VBA函數進行顏色篩選的操作方法




