Function WhatIsIt(ByVal a As Variant)
If IsArray(a) Then
If TypeName(a) = "Range" Then a = a.Value
If Application.IsErr(Application.Index(a, UBound(a), 1)) Then
WhatIsIt = "array 1 dimension (colonne) de " & UBound(a) + 1 - LBound(a) & " valeurs."
Else
WhatIsIt = "Array 2 dimensions, Colonnes : " & UBound(a, 2) + 1 - LBound(a, 2) & " ,Lignes : " & UBound(a, 1) + 1 - LBound(a, 1)
End If
Else
If TypeName(a) = "Range" Then a = a.Value
If TypeName(a) <> "Variant()" Then WhatIsIt = TypeName(a)
End If
End Function
Sub testy01()
Dim Liste As Variant
Liste = Array(1, 2, 3, 4, 5, 6)
MsgBox WhatIsIt(Liste)
End Sub
Sub testy02()
Dim Liste(1 To 50, 1 To 10) As Variant, Compteur%, Compteur2%
For Compteur = 1 To 50
For Compteur2 = 1 To 10
Liste(Compteur, Compteur2) = Compteur * Compteur2
Next Compteur2
Next Compteur
MsgBox WhatIsIt(Liste)
End Sub
Sub testy03()
Dim Liste As Variant
Set Liste = [A1:A13]
MsgBox WhatIsIt(Liste)
End Sub
Sub testy04()
Dim Liste As Variant
Set Liste = [A1:H1]
MsgBox WhatIsIt(Liste)
End Sub
Sub testy05()
Dim Liste As Variant
Liste = "1,2,3,4,5,6,7,8,9"
MsgBox WhatIsIt(Liste)
End Sub
Sub testy06()
Dim Liste As Variant
Liste = 12.36
MsgBox WhatIsIt(Liste)
End Sub
Sub testy07()
Dim a
a = [A1:H1].Value
MsgBox WhatIsIt(a)
End Sub
Sub testy08()
Dim a
a = Array(1, 2, 3, 4, 5, 6, 7, 8, 9)
MsgBox WhatIsIt(a)
End Sub
Sub testy09()
Dim a(0 To 5, 1)
a(5, 0) = "toto "
MsgBox WhatIsIt(a)
End Sub
Sub testy10()
Dim a(0 To 5, 0)
a(0, 0) = "toto1 "
a(1, 0) = "toto2 "
a(2, 0) = "toto3 "
a(3, 0) = "toto4 "
a(4, 0) = "toto5 "
a(5, 0) = "toto6 "
MsgBox WhatIsIt(a)
End Sub
Sub testy11()
Dim Liste As Variant
Liste = Array("essai1", "essai2", "essai3", "essai4", "essai5", "essai6")
MsgBox WhatIsIt(Liste)
End Sub