Option Explicit
Private Type tRangeFormat
Address() As String 'Adresse de la cellule en cours
Bold() As String 'Si la cellule en cours est en gras
Italic() As String 'Si la cellule en cours est en italique
Underline() As String 'Si la cellule en cours est soulignée (tous les modes compris)
StrikeTrough() As String 'Si la cellule en cours est barrée
Superscript() As String 'Si la cellule en cours est en exposant
Subscript() As String 'Si la cellule en cours est en indice
End Type
Public Function RangeFormat(ByVal MyRange As Range) As tRangeFormat
Dim rCell As Range, i As Integer
Dim uStyleVerif As XlUnderlineStyle
i = -1
With RangeFormat
For Each rCell In MyRange
i = i + 1
ReDim Preserve RangeFormat.Address(i)
ReDim Preserve RangeFormat.Bold(i)
ReDim Preserve RangeFormat.Italic(i)
ReDim Preserve RangeFormat.Underline(i)
ReDim Preserve RangeFormat.StrikeTrough(i)
ReDim Preserve RangeFormat.Superscript(i)
ReDim Preserve RangeFormat.Subscript(i)
.Address(i) = rCell.Address
.Bold(i) = "Gras : " & CBool(rCell.Font.Bold)
.Italic(i) = "Italique : " & CBool(rCell.Font.Italic)
.Underline(i) = "Soulignée : " & IIf(rCell.Font.Underline > 0, "Vrai", "Faux")
.StrikeTrough(i) = "Barrée : " & CBool(rCell.Font.Strikethrough)
.Superscript(i) = "Exposant : " & CBool(rCell.Font.Superscript)
.Subscript(i) = "Indice : " & CBool(rCell.Font.Subscript)
Next rCell
End With
End Function
Sub EXEMPLE()
Dim i As Integer, MyRangeFormat As tRangeFormat
MyRangeFormat = RangeFormat(Range("A1:A4"))
For i = LBound(MyRangeFormat.Address) To UBound(MyRangeFormat.Address)
Debug.Print MyRangeFormat.Address(i)
Debug.Print MyRangeFormat.Bold(i)
Debug.Print MyRangeFormat.Italic(i)
Debug.Print MyRangeFormat.Underline(i)
Debug.Print MyRangeFormat.StrikeTrough(i)
Debug.Print MyRangeFormat.Superscript(i)
Debug.Print MyRangeFormat.Subscript(i) & vbCrLf
Next i
End Sub