我需要一个函数,该函数在$ ctags --version
Exuberant Ctags 5.8, Copyright (C) 1996-2009 Darren Hiebert
Compiled: Feb 12 2019, 19:25:46
Addresses: <dhiebert@users.sourceforge.net>, http://ctags.sourceforge.net
Optional compiled features: +wildcards, +regex
函数中将经过过滤的数据范围作为参数传递。但是,我的代码隐藏了循环中所有为空的行。
仅当过滤后的可见数据计数(例如G5,T5,AG5为零)为零时,才应隐藏行的预期输出。
HideRangeIfEmpty
答案 0 :(得分:0)
您可以通过将多个相关字段指定为多个范围来将它们分别作为单独的区域:
Private Sub UsGe()
' ...
Call HideRangeIfEmpty(ActiveSheet.Range("G6:G200, T6:T200, AG6:AG200"))
End Sub
如果该列的任何值为<>“”,则将显示该行,否则不显示:
Private Sub HideRangeIfEmpty(ByRef r As Range)
Dim CurrentRow As Long, CurrentArea As Long, CurrentColumn As Long
Dim ToBeShown As Boolean
' Check each row (defined by the first area)
For CurrentRow = 1 To r.Areas(1).Rows.Count
ToBeShown = False ' default: not hidden
' check each area (one or more columns)
For CurrentArea = 1 To r.Areas.Count
' check cell in each column
For CurrentColumn = 1 To r.Areas(CurrentArea).Columns.Count
' If any has a value, then set the marker
If r.Areas(CurrentArea).Cells(CurrentRow, CurrentColumn) <> "" Then _
ToBeShown = True
Next CurrentColumn
Next CurrentArea
' show complete row, if marker is set
r.Areas(1).Cells(CurrentRow, 1).EntireRow.Hidden = Not ToBeShown
Next CurrentRow
End Sub
现在它还可以与“ G6:I200”之类的范围一起使用,我的代码将在其中检查G,H和I列。