
yoarf
|
Voilà je voudrais en fait "réduire" ce code suivant (c un peu l'usine à gaz) :
Dim val As Integer Dim num_ligne As Integer Dim cat As String
Dim T_banque_d(1 To 12, 2009 To 2100) As Single Dim T_banque_c(1 To 12, 2009 To 2100) As Single Dim T_salaire_c(1 To 12, 2009 To 2100) As Single Dim T_logement_d(1 To 12, 2009 To 2100) As Single Dim T_logement_c(1 To 12, 2009 To 2100) As Single Dim T_equipement_d(1 To 12, 2009 To 2100) As Single Dim T_electricite_d(1 To 12, 2009 To 2100) As Single Dim T_nourriture_d(1 To 12, 2009 To 2100) As Single Dim T_diversloisirs_d(1 To 12, 2009 To 2100) As Single Dim T_diversloisirs_c(1 To 12, 2009 To 2100) As Single Dim T_impotsassurance_d(1 To 12, 2009 To 2100) As Single Dim T_vetement_d(1 To 12, 2009 To 2100) As Single Dim T_sante_d(1 To 12, 2009 To 2100) As Single Dim T_sante_c(1 To 12, 2009 To 2100) As Single Dim T_telephonie_d(1 To 12, 2009 To 2100) As Single Dim T_transport_d(1 To 12, 2009 To 2100) As Single Dim T_remboursements_c(1 To 12, 2009 To 2100) As Single
num_ligne = 2
While Worksheets("TRANSACTIONS").Cells(num_ligne, 1).Value <> "" If (Month(Worksheets("TRANSACTIONS").Cells(num_ligne, 1).Value)) = 1 And (Year(Worksheets("TRANSACTIONS").Cells(num_ligne, 1).Value)) = 2009 Then
cat = Worksheets("TRANSACTIONS").Cells(num_ligne, 7).Value
If Worksheets("TRANSACTIONS").Cells(num_ligne, 7).Interior.ColorIndex = 10 Then type_valorisation = "c" End If
If Worksheets("TRANSACTIONS").Cells(num_ligne, 7).Interior.ColorIndex = 45 Then type_valorisation = "d" End If
nomtab = "T_" & LCase(cat) & "_" & type_valorisation '***** If nomtab = "T_banque_d" Then T_banque_d(1, 2009) = T_banque_d(1, 2009) + Worksheets("TRANSACTIONS").Cells(num_ligne, 3).Value End If If nomtab = "T_banque_c" Then T_banque_c(1, 2009) = T_banque_c(1, 2009) + Worksheets("TRANSACTIONS").Cells(num_ligne, 4).Value End If If nomtab = "T_salaire_c" Then T_salaire_c(1, 2009) = T_salaire_c(1, 2009) + Worksheets("TRANSACTIONS").Cells(num_ligne, 4).Value End If If nomtab = "T_logement_d" Then T_logement_d(1, 2009) = T_logement_d(1, 2009) + Worksheets("TRANSACTIONS").Cells(num_ligne, 3).Value End If If nomtab = "T_logement_c" Then T_logement_c(1, 2009) = T_logement_c(1, 2009) + Worksheets("TRANSACTIONS").Cells(num_ligne, 4).Value End If If nomtab = "T_equipement_d" Then T_equipement_d(1, 2009) = T_equipement_d(1, 2009) + Worksheets("TRANSACTIONS").Cells(num_ligne, 3).Value End If If nomtab = "T_electricite_d" Then T_electricite_d(1, 2009) = T_electricite_d(1, 2009) + Worksheets("TRANSACTIONS").Cells(num_ligne, 3).Value End If If nomtab = "T_nourriture_d" Then T_nourriture_d(1, 2009) = T_nourriture_d(1, 2009) + Worksheets("TRANSACTIONS").Cells(num_ligne, 3).Value End If If nomtab = "T_diversloisirs_d" Then T_diversloisirs_d(1, 2009) = T_diversloisirs_d(1, 2009) + Worksheets("TRANSACTIONS").Cells(num_ligne, 3).Value End If If nomtab = "T_diversloisirs_c" Then T_diversloisirs_c(1, 2009) = T_diversloisirs_c(1, 2009) + Worksheets("TRANSACTIONS").Cells(num_ligne, 3).Value End If If nomtab = "T_impotsassurance_d" Then T_impotsassurance_d(1, 2009) = T_impotsassurance_d(1, 2009) + Worksheets("TRANSACTIONS").Cells(num_ligne, 3).Value End If If nomtab = "T_vetement_d" Then T_vetement_d(1, 2009) = T_vetement_d(1, 2009) + Worksheets("TRANSACTIONS").Cells(num_ligne, 3).Value End If If nomtab = "T_sante_d" Then T_sante_d(1, 2009) = T_sante_d(1, 2009) + Worksheets("TRANSACTIONS").Cells(num_ligne, 3).Value End If If nomtab = "T_sante_c" Then T_sante_c(1, 2009) = T_sante_c(1, 2009) + Worksheets("TRANSACTIONS").Cells(num_ligne, 4).Value End If If nomtab = "T_telephonie_d" Then T_telephonie_d(1, 2009) = T_telephonie_d(1, 2009) + Worksheets("TRANSACTIONS").Cells(num_ligne, 3).Value End If If nomtab = "T_transport_d" Then T_transport_d(1, 2009) = T_transport_d(1, 2009) + Worksheets("TRANSACTIONS").Cells(num_ligne, 3).Value End If If nomtab = "T_remboursements_c" Then T_remboursements_c(1, 2009) = T_remboursements_c(1, 2009) + Worksheets("TRANSACTIONS").Cells(num_ligne, 4).Value End If '***** End If
num_ligne = num_ligne + 1
Wend
Worksheets("Répartition").Cells(5, 4).Value = T_banque_d(1, 2009) Worksheets("Répartition").Cells(5, 5).Value = T_banque_c(1, 2009) Worksheets("Répartition").Cells(5, 6).Value = T_salaire_c(1, 2009) Worksheets("Répartition").Cells(5, 7).Value = T_logement_d(1, 2009) Worksheets("Répartition").Cells(5, 8).Value = T_logement_c(1, 2009) Worksheets("Répartition").Cells(5, 9).Value = T_equipement_d(1, 2009) Worksheets("Répartition").Cells(5, 10).Value = T_electricite_d(1, 2009) Worksheets("Répartition").Cells(5, 11).Value = T_nourriture_d(1, 2009) Worksheets("Répartition").Cells(5, 12).Value = T_diversloisirs_d(1, 2009) Worksheets("Répartition").Cells(5, 13).Value = T_diversloisirs_c(1, 2009) Worksheets("Répartition").Cells(5, 14).Value = T_impotsassurance_d(1, 2009) Worksheets("Répartition").Cells(5, 15).Value = T_vetement_d(1, 2009) Worksheets("Répartition").Cells(5, 17).Value = T_sante_d(1, 2009) Worksheets("Répartition").Cells(5, 17).Value = T_sante_c(1, 2009) Worksheets("Répartition").Cells(5, 18).Value = T_telephonie_d(1, 2009) Worksheets("Répartition").Cells(5, 19).Value = T_transport_d(1, 2009) Worksheets("Répartition").Cells(5, 20).Value = T_remboursements_c(1, 2009)
|