Bonjour,
J'ai un petit problème avec la fonction transpose, mais que sur certains ordinateur.
Le script permet de recherche la date la plus éloigné suivant une référence unique et transpose le résultat sur une autre colonne. (Voir fichier). Sur mon ordinateur aucun problème, il y a que sur d'autre ordinateur ou j'ai une erreur d'incompatibilité 13 sur les lignes:
Sheets("Matrice").Range("L2").Resize(UBound(a) + 1) = Application.Transpose(a)
Sheets("Matrice").Range("M2").Resize(UBound(b) + 1) = Application.Transpose(b)
Code entier:
Sub TANSP()
tablo = Sheets("Matrice").Range("A2:B" & Sheets("Matrice").Range("A65535").End(xlUp).Row)
Set dico = CreateObject("Scripting.dictionary")
For n = LBound(tablo, 1) To UBound(tablo, 1)
x = tablo(n, 1)
On Error Resume Next
If CDbl(tablo(n, 2)) > dico(x) Then
Cells.SpecialCells(xlCellTypeFormulas, xlErrors).ClearContents
dico(x) = CDbl(tablo(n, 2))
Else
End If
On Error GoTo 0
Next
a = dico.keys
b = dico.items
For n = LBound(a) To UBound(a)
For m = LBound(a) To UBound(a)
If a(m) > a(n) Then
tempa = a(m)
tempb = b(m)
a(m) = a(n)
b(m) = b(n)
a(n) = tempa
b(n) = tempb
End If
Next
Next
8-) Sheets("Matrice").Range("L2").Resize(UBound(a) + 1) = Application.Transpose(a)
Sheets("Matrice").Range("M2").Resize(UBound(b) + 1) = Application.Transpose(b)
Set tablo = Nothing
Set dico = Nothing
Set x = Nothing
Set n = Nothing
Set a = Nothing
Set b = Nothing
Set m = Nothing
End Sub
Après quelque essais, je vois pas comment il est possible d'avoir se bug, que sur 2 ordinateur sur 10. le script étant assez simplifier je bloque un peu...
Merci d'avance pour votre aide,