'La façon la plus simple
Sub Test1()
Dim nbreL As Long, nbreC As Long
nbreL = Range("B2").CurrentRegion.Rows.Count
nbreC = Range("B2").CurrentRegion.Columns.Count
MsgBox nbreL & vbCrLf & nbreC
End Sub
'Plus compliqué
Sub Test2()
Dim t
Dim nbreL As Long, nbreC As Long
t = TailleTableau(Range("B2").CurrentRegion)
If IsArray(t) Then
nrbeL = t(0)
nbreC = t(1)
End If
MsgBox nbreL & vbCrLf & nbreC
End Sub
'solution 3
'Avec cette solution s'il n'y a pas
'au moins une cellule occupée sous B2 ou une colonne occupée à droite de B2
'.End(xlDown) renverra la dernière ligne de la feuille
'.End(xlToRight renverra la dernière colonne de la feuille
Sub Test3()
Dim nbreL As Long, nbreC As Long
With Range("B2")
nbreL = .End(xlDown).Row - .Row + 1
nbreC = .End(xlToRight).Column - .Column + 1
End With
MsgBox nbreL & vbCrLf & nbreC
End Sub
Function TailleTableau(PlageCellules As Range) As Variant
TailleTableau = Array(PlageCellules.Rows.Count, PlageCellules.Columns.Count)
End Function