此HideEmptyColumns()
宏隐藏所有没有任何数据的列。如何修改它以使其忽略标题行(第 1 行)?
Sub HideEmptyColumns()
Dim Col As Range
For Each Col In ActiveSheet.UsedRange.Columns
Col.EntireColumn.Hidden = RangeIsEmpty(Col)
Next Col
End Sub
Function RangeIsEmpty(R As Range) As Boolean
Dim Cell As Range
RangeIsEmpty = True
For Each Cell In R.Cells
If Cell.Value <> "" Then
RangeIsEmpty = False
Exit For
End If
Next Cell
End Function