1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| Sub essai()
'MsgBox Application.CountIf(Cells, Cells.SpecialCells(xlCellTypeFormulas))
Dim rng As Range, RgAdresse, adresseFinal, dicoRange
Set rng = Cells
Set dicoRange = CreateObject("Scripting.Dictionary")
If Not Cells.Find("*", LookIn:=xlFormulas) Is Nothing Then
Union(rng.SpecialCells(xlCellTypeConstants), rng.SpecialCells(xlCellTypeFormulas)).Select
Else
rng.SpecialCells(xlCellTypeConstants, 23).Select
End If
RgAdresse = Split(Selection.Address, ",")
For i = 0 To UBound(RgAdresse)
Set region = Range(RgAdresse(i), RgAdresse(i)).CurrentRegion
dicoexist = dicoRange.exists(region.Address) = True
dicoRange(region.Address) = IIf(dicoexist, dicoRange(region.Address) & RgAdresse(i) & ",", "(" & RgAdresse(i) & ",")
Next
For Each elem In dicoRange
dicoRange(elem) = Replace(dicoRange(elem) & ")", ",)", ")")
'MsgBox elem & " :" & dicoRange(elem)
adresseFinal = adresseFinal & " " & dicoRange(elem)
Next
MsgBox adresseFinal
End Sub |
Partager