Sub
CountIF_Demo()
Dim
rngSearch
As
Range, lastCol
As
Long
, lastRow
As
Long
, c
As
Long
With
Worksheets(
"Tabelle1"
)
lastCol = .Cells(2, .Columns.Count).
End
(xlToLeft).Column
lastRow = .UsedRange.Find(
"*"
, SearchDirection:=xlPrevious).Row
Set
rngSearch = .Range(.Cells(6,
"D"
), .Cells(lastRow, lastCol))
For
c = 4
To
lastCol
.Cells(4, c).Value = WorksheetFunction.CountIf(rngSearch.Columns(c - 3), .Cells(2, c).Value)
Next
c
End
With
End
Sub