Option
Explicit
Sub
spaltenAusblenden()
Dim
c
As
Integer
, cols
As
Integer
, i
As
Integer
, lastCol
As
Integer
, hiddenCols
As
Integer
, colsToHide
lastCol = Sheets(
"Tabelle1"
).Cells(1, Columns.Count).
End
(xlToLeft).Column
hiddenCols = ausgeblendeteSpaltenZaehlen
i = lastCol - hiddenCols - 22
If
i > 0
Then
colsToHide = 23 + hiddenCols
With
Sheets(
"Tabelle1"
)
.Range(.Cells(1, colsToHide), .Cells(1, lastCol)).Columns.Hidden =
True
End
With
End
If
End
Sub
Function
ausgeblendeteSpaltenZaehlen()
Dim
a
As
Integer
, c
As
Integer
, lc
As
Integer
lc = Sheets(
"Tabelle1"
).Cells(1, Columns.Count).
End
(xlToLeft).Column
For
a = 1
To
lc
If
ActiveSheet.Columns(a).EntireColumn.Hidden =
True
Then
c = c + 1
Next
a
ausgeblendeteSpaltenZaehlen = c
End
Function