1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
|
Function feuille_titre(fichier_concerné, range_concerné)
ref = Workbooks(fichier_concerné).Names(range_concerné).RefersTo
'la condition if est seulement une précaution contre les confusions de références de noms identifiques. Les refersto apparaissent alors avec tout le chemin du fichier, donc le ".xls"
'cette condition est normalement inutile
If InStr(ref, ".xls") = 0 Then feuille_titre = Left(Right(ref, Len(ref) - 2), InStr(Right(ref, Len(ref) - 2), "'!") - 1)
End Function
Function colonne_titre(fichier_concerné, range_concerné)
ref = Workbooks(fichier_concerné).Names(range_concerné).RefersTo
addresse = Right(ref, Len(ref) - InStr(ref, "!$") - 1)
colonne_alphabet = Left(addresse, InStr(addresse, "$") - 1)
colonne_titre = 26 * InStr("ABCDEFGHIJKLMNOPQRSTUVWXYZ", Left(colonne_alphabet, 1)) * (Len(colonne_alphabet) - 1) + InStr("ABCDEFGHIJKLMNOPQRSTUVWXYZ", Right(colonne_alphabet, 1))
'comme Len(colonne_alphabet) ne peut etre supérieur à 2 jusqu'à excel 2003, (Len(colonne_alphabet) - 1) permet d'annuler cette première partie s'il s'agit d'une référence à colonne unique
End Function
Function ligne_titre(fichier_concerné, range_concerné)
ref = Workbooks(fichier_concerné).Names(range_concerné).RefersTo
addresse = Right(ref, Len(ref) - InStr(ref, "!$") - 1)
ligne_titre = Right(addresse, Len(addresse) - InStr(addresse, "$"))
End Function |
Partager