Hello Forum, Hello bouben
Je reviens vers toi, car j'avais un petit problème de Windows, après réinstallation complète je peux de nouveau avoir une listview dans excel .
Ma question est ce que ça serait possible d'avoir une listview à la place de la listbox ?
J'ai essayé quelque modif par moi même mais ça bloque vers la fin. Le code principal je pense se trouve ici, sinon tout est dans le dernier fichier. ( VariationMarques-V0.3.xls)
Voilà si toi ou quelqu'un d'autre pouvais me donner un coup de ça serait génial.
Private Sub Recherche()
Dim dMtA As Double
Dim dMtPrec As Double
Dim dtA As Date
Dim dtPrec As Date
Dim sMtA As String 'pour affichage
Dim sMtPrec As String 'pour affichage
Dim sTopA As String
Dim sTopPrec As String
Dim sVariation As String 'pour affichage
Dim oMarque As clsMarque
Dim oPrixA As clsPrix
Dim oPrixPrec As clsPrix
'MsgBox mcolMarques.Count
ListBox1.Clear '>>>> j'avais mis ça ListView1.ListItems.Clear
dtA = ComboBox1.Value
dtPrec = DateAdd("d", -1, dtA) ' >>> "d" = day
For Each oMarque In mcolMarques
'recherche prix à date
Set oPrixA = oMarque.PrixDate(dtA)
If oPrixA Is Nothing Then
dMtA = 0
sMtA = ""
sTopA = ""
Else
dMtA = oPrixA.Prix
sMtA = Format(dMtA, "### ### ###")
sTopA = oPrixA.TopX
End If
'recherche prix à date antérieure
Set oPrixPrec = oMarque.PrixPrec(dtA)
If oPrixPrec Is Nothing Then
dMtPrec = 0
sMtPrec = ""
sTopPrec = ""
Else
dMtPrec = oPrixPrec.Prix
sMtPrec = Format(dMtPrec, "### ### ###")
sTopPrec = oPrixPrec.TopX
End If
'MsgBox oMarque.Marque & vbCrLf & "Mt A : " & dMtA & vbCrLf & "Mt préc : " & dMtPrec, vbExclamation
If dMtA = 0 Or dMtPrec = 0 Then
'un seul prix : pas de variation
sVariation = ""
Else
sVariation = Format(dMtA - dMtPrec, "### ### ###")
End If
' MsgBox "Marque : " & sMarque & vbCrLf & "Ecart : " & dVariation, vbExclamation
'If dMtA <> 0 Or dMtPrec <> 0 Then
If dMtA <> 0 Then
ListBox1.AddItem oMarque.Marque ' >> et ici je commence a bloquer :-)
ListBox1.List(ListBox1.ListCount - 1, 1) = sMtPrec
ListBox1.List(ListBox1.ListCount - 1, 2) = sTopPrec
ListBox1.List(ListBox1.ListCount - 1, 3) = sMtA
ListBox1.List(ListBox1.ListCount - 1, 4) = sTopA
ListBox1.List(ListBox1.ListCount - 1, 5) = sVariation
End If
Set oPrixA = Nothing
Set oPrixPrec = Nothing
Next oMarque
End Sub