Cette action est irreversible, confirmez la suppression du commentaire ?
Signaler le commentaire
Veuillez sélectionner un problème
Nudité
Violence
Harcèlement
Fraude
Vente illégale
Discours haineux
Terrorisme
Autre
FxM
Bonjour,
Est-il possible qu'une fonction personnalisée créée en VBA renvoie un tableau ? Si oui, comment faire ? Si non, y a-t-il une alternative ?
Merci pour votre aide.
Bonsoir Patrick,
alt-f11 | insertion | module Public Function table1() Dim tablo a = 1: b = 2: ReDim tablo(1, 2) For c = 0 To a For d = 0 To b tablo(c, d) = c & " / " & d Next d Next c ' table1 = tablo 'choix1 table1 = Application.Transpose(tablo) 'choix2 End Function
dans ta feuille de calculs : si tu actives choix2 -> sélectionne A1:B3, tapes =table1() puis validation matricielle
si tu actives choix1 -> sélectionne A1:C2, tapes =table1() puis validation matricielle
Donc oui, il est possible de ... :o)
@+ FxM
Bonjour,
Est-il possible qu'une fonction personnalisée créée en VBA renvoie un
tableau ?
Si oui, comment faire ? Si non, y a-t-il une alternative ?
Merci pour votre aide.
Bonsoir Patrick,
alt-f11 | insertion | module
Public Function table1()
Dim tablo
a = 1: b = 2: ReDim tablo(1, 2)
For c = 0 To a
For d = 0 To b
tablo(c, d) = c & " / " & d
Next d
Next c
' table1 = tablo 'choix1
table1 = Application.Transpose(tablo) 'choix2
End Function
dans ta feuille de calculs :
si tu actives choix2 -> sélectionne A1:B3, tapes =table1() puis
validation matricielle
si tu actives choix1 -> sélectionne A1:C2, tapes =table1() puis
validation matricielle
Est-il possible qu'une fonction personnalisée créée en VBA renvoie un tableau ? Si oui, comment faire ? Si non, y a-t-il une alternative ?
Merci pour votre aide.
Bonsoir Patrick,
alt-f11 | insertion | module Public Function table1() Dim tablo a = 1: b = 2: ReDim tablo(1, 2) For c = 0 To a For d = 0 To b tablo(c, d) = c & " / " & d Next d Next c ' table1 = tablo 'choix1 table1 = Application.Transpose(tablo) 'choix2 End Function
dans ta feuille de calculs : si tu actives choix2 -> sélectionne A1:B3, tapes =table1() puis validation matricielle
si tu actives choix1 -> sélectionne A1:C2, tapes =table1() puis validation matricielle
Function SansDoublons(champ As Range) Dim temp() ReDim temp(1 To champ.Count, 1 To 1) ' 2 dimensions j = 1 For i = 1 To champ.Count If IsError(Application.Match(champ(i), temp, 0)) _ And champ(i) <> "" And champ(i) <> 0 Then temp(j, 1) = champ(i): j = j + 1 End If Next i SansDoublons = temp End Function
Function SansDoublonsTrié(champ As Range) Dim temp() ReDim temp(1 To champ.Count) ' 1 dimension j = 1 For i = 1 To champ.Count If IsError(Application.Match(champ(i), temp, 0)) _ And champ(i) <> "" And champ(i) <> 0 Then temp(j) = champ(i): j = j + 1 End If Next i Call tri(temp, 1, j - 1) SansDoublonsTrié = Application.Transpose(temp) End Function
Cordialement JB
Bonjour,
Est-il possible qu'une fonction personnalisée créée en VBA renvoie un tableau ? Si oui, comment faire ? Si non, y a-t-il une alternative ?
Function SansDoublons(champ As Range)
Dim temp()
ReDim temp(1 To champ.Count, 1 To 1) ' 2 dimensions
j = 1
For i = 1 To champ.Count
If IsError(Application.Match(champ(i), temp, 0)) _
And champ(i) <> "" And champ(i) <> 0 Then
temp(j, 1) = champ(i): j = j + 1
End If
Next i
SansDoublons = temp
End Function
Function SansDoublonsTrié(champ As Range)
Dim temp()
ReDim temp(1 To champ.Count) ' 1 dimension
j = 1
For i = 1 To champ.Count
If IsError(Application.Match(champ(i), temp, 0)) _
And champ(i) <> "" And champ(i) <> 0 Then
temp(j) = champ(i): j = j + 1
End If
Next i
Call tri(temp, 1, j - 1)
SansDoublonsTrié = Application.Transpose(temp)
End Function
Cordialement JB
Bonjour,
Est-il possible qu'une fonction personnalisée créée en VBA renvoie un
tableau ?
Si oui, comment faire ? Si non, y a-t-il une alternative ?
Function SansDoublons(champ As Range) Dim temp() ReDim temp(1 To champ.Count, 1 To 1) ' 2 dimensions j = 1 For i = 1 To champ.Count If IsError(Application.Match(champ(i), temp, 0)) _ And champ(i) <> "" And champ(i) <> 0 Then temp(j, 1) = champ(i): j = j + 1 End If Next i SansDoublons = temp End Function
Function SansDoublonsTrié(champ As Range) Dim temp() ReDim temp(1 To champ.Count) ' 1 dimension j = 1 For i = 1 To champ.Count If IsError(Application.Match(champ(i), temp, 0)) _ And champ(i) <> "" And champ(i) <> 0 Then temp(j) = champ(i): j = j + 1 End If Next i Call tri(temp, 1, j - 1) SansDoublonsTrié = Application.Transpose(temp) End Function
Cordialement JB
Bonjour,
Est-il possible qu'une fonction personnalisée créée en VBA renvoie un tableau ? Si oui, comment faire ? Si non, y a-t-il une alternative ?