'----------------------------------------------------------------------
'Calcul de la dernière ligne non vide d'une colonne avec fonction Match
'Colonne: numéro ou lettre
'----------------------------------------------------------------------
Function MatchDernièreLigneEnColonne(ByVal Feuille As Worksheet, ByVal Colonne As Variant) As Long
Const ChaineMax As String = "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"
Const NombreMax As Double = (2 ^ 53 - 1) * 2 ^ 971
Dim RngColonne As Range
Dim RngFormulaErrors As Range
Dim MaxErrorLine As Long
Set RngColonne = Feuille.Columns(Colonne)
On Error Resume Next
Set RngFormulaErrors = RngColonne.SpecialCells(xlCellTypeFormulas, xlErrors)
If Err.Number = 0 Then
Set RngFormulaErrors = RngFormulaErrors.Areas(RngFormulaErrors.Areas.Count)
MaxErrorLine = RngFormulaErrors.Cells(RngFormulaErrors.Cells.Count).Row
End If
On Error GoTo 0
With Application
MatchDernièreLigneEnColonne = .Max(.IfError(.Match(ChaineMax, RngColonne, 1), 0), _
.IfError(.Match(NombreMax, RngColonne, 1), 0), _
MaxErrorLine)
End With
End Function