Option Explicit
' ======
' EN FAIRE UNE CLASSE! Plus cool
' Avec fonction de concatenation "automatique" des tableaux
Type Result_Type
Value() As Variant
Address() As String
LeType() As Variant
End Type
Dim Tablo() As Result_Type
' ======
Sub Test_récup_plage()
Dim I, J, K
Dim Fichier$, Item
Dim MyRge
Set MyRge = Range("C1:C3,C5:C6")
ReDim Tablo(1 To MyRge.Areas.Count)
ReDim T(1 To MyRge.Areas.Count)
Fichier = "E:\FONCTIONS VBA PERSO\TESTS\Datas externes.xlsx" 'à adapter
' NOTE! Le passage d'adresses préfixées $Ligne$Colon ne marche pas.
For Each Item In MyRge.Areas
I = I + 1
ReDim Tablo(I).Address(1 To Item.Rows.Count, 1 To Item.Columns.Count)
' Sauve les adresses
For J = 1 To Item.Rows.Count
For K = 1 To Item.Columns.Count
Tablo(I).Address(J, K) = Item.Cells(J, K).Address(False, False)
Next K
Next J
ReDim Tablo(I).Value(1 To Item.Rows.Count, 1 To Item.Columns.Count)
ReDim Tablo(I).LeType(1 To Item.Rows.Count, 1 To Item.Columns.Count)
T(I) = GetUserRangeOnClosedFich2(I, Fichier, Item.Address(False, False), "Feuil1", False)
Next Item
' [A1].Resize(UBound(T), UBound(T, 2)) = T
For I = 1 To UBound(Tablo)
For J = 1 To UBound(Tablo(I).Value)
For K = 1 To UBound(Tablo(I).Value, 2)
Debug.Print "Valeur: ", Tablo(I).Value(J, K)
Debug.Print "Adresse: ", Tablo(I).Address(J, K)
Debug.Print "Type: ", Tablo(I).LeType(J, K)
Next K
Next J
Debug.Print "========"
Next I
End Sub