Sub testy7() 'test tableau ligne ligne renvoie 11 ou 14( pas bon )
Dim liste
a = [A1:z1].Value
MsgBox WhatIsIt(a)
ReDim liste(1, 0 To 5)
MsgBox WhatIsIt(liste)
ReDim liste(0, 1 To 5)
MsgBox WhatIsIt(liste)
ReDim liste(1 To 1, 1 To 5)
MsgBox WhatIsIt(liste)
End Sub
Sub testy3() ' test tableau colonne renvoi 14
Dim liste As Variant
liste = [A1:A10].Value
MsgBox WhatIsIt(liste)
ReDim liste(0 To 5, 1 To 1)
MsgBox WhatIsIt(liste)
ReDim liste(0 To 5, 0)
MsgBox WhatIsIt(liste)
End Sub
Sub testy1() 'test array renvoie 3
Dim liste As Variant
liste = Array(1, 2, 3, 4, 5, 6)
MsgBox WhatIsIt(liste)
ReDim liste(1 To 10)
MsgBox WhatIsIt(liste)
MsgBox WhatIsIt(Split("toto,toto,titi,riri,fifi", ","))
End Sub
Function WhatIsIt(ByVal quoi As Variant)
On Error Resume Next
x = UBound(quoi, 2):
If Err.Number > 0 Then WhatIsIt = "array": Err.Clear: Exit Function
If UBound(quoi) > 0 Then WhatIsIt = "colonne"
ind = IIf(UBound(quoi, 2) = 0, 1, UBound(quoi, 2))
WhatIsIt = IIf(ind >= 2, "ligne", "colonne")
Err.Clear
End Function