Gruppe
UDF
Problem
Über eine benutzerdefinierte Funktion soll die Anzahl der Zellen in einem nicht rechteckig umrahmten Bereich ermittelt werden.
StandardModule: Modul1
Function CellsCount(rng As Range) As Integer
Dim lRow As Long
Dim iCol As Integer, iCounter As Integer
For lRow = rng.Row To ActiveSheet.Rows.Count
For iCol = rng.Column To ActiveSheet.Columns.Count
iCounter = iCounter + 1
If Cells(lRow, iCol).Borders(xlEdgeRight).Weight = xlMedium Then
Exit For
End If
Next iCol
iCol = rng.Column
If Cells(lRow, iCol).Borders(xlEdgeBottom).Weight = xlMedium Then
Exit For
End If
Next lRow
CellsCount = iCounter
End Function
Sub Test()
MsgBox Range("H30").Borders(xlEdgeRight).Weight
End Sub