我有一个数据库,其类别标题包含.Interior.Color和.Font格式,当单击类别标题单元格时,它将应用于选定的行.
我想添加一个功能,当双击类别标题单元格时,文档中与该类别不匹配的所有行都将被隐藏.
我在Sheet1(代码)中添加了以下内容:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, HideRow As
Boolean)
If Not Application.Intersect(Target, Range("C1:W1")) Is Nothing Then
LstRow = Cells.Find(What:="*", After:=Range("A1"), lookat:=xlPart, _
LookIn:=xlFormulas, SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious, MatchCase:=False).Row
'Finds last row with data
Set Dyn_AllEntries = ActiveSheet.Range("C5:C" & LstRow) 'range w/ all data
If HiddenRows <> True Then 'Checks to see if the macro was already run
For Each cl In Dyn_AllEntries
If cl.Offset(0, 11) <> Target Then 'check if category matches
cl.EntireRow.Hidden = True 'if not, hide …Run Code Online (Sandbox Code Playgroud)