Function NomColonne(Optional ByVal Rg As Range, Optional ByVal Déf As String = "")
If Rg Is Nothing Then Set Rg = Application.Caller
NomColonne = NomPlage(Rg.EntireColumn, Déf)
End Function
Function NomPlage(Optional ByVal Rg As Range, Optional ByVal Déf As String = "") As String
Dim Nom As String
If Rg Is Nothing Then
Set Rg = Application.Caller
Nom = NomPlage(Rg.Offset(1, 0))
If Nom = "" Then Nom = NomPlage(Rg.Offset(0, 1))
If Nom = "" Then Nom = NomPlage(Rg.Offset(-1, 0))
If Nom = "" Then Nom = NomPlage(Rg.Offset(0, -1))
Else
On Error Resume Next: Nom = Rg.Name.Name
If Err <> 0 Then NomPlage = Déf: Exit Function
End If
NomPlage = Mid$(Nom, PosPExcla(Nom) + 1)
End Function
Function PosPExcla(ByVal Z As String) As Long
Rem. Le nom de feuille peut contenir "!", et même "'!", ou commencer par "!", pourquoi pas, mais on ne peut
' se contenter de chercher tout simplement le dernier "!" car la suite de Z peut aussi contenir "#REF!" !
If Left$(Z, 1) = "'" Then PosPExcla = InStr(Replace(Mid$(Z, 2), "''", "??"), "'!") + 2 Else PosPExcla = InStr(Z, "!")
End Function