Bonjour; (DÉBUTANT)
J'aimerai savoir si ces deux codes peuvent ils etre simplifié
Je vous en remercie par avance de vos reponses.
Cordialement
J'aimerai savoir si ces deux codes peuvent ils etre simplifié
Code:
Sub Cal()
Dim i As Integer
'Test de cellule non vide sur la colonne D (affecte sur variable mais aussi dans une cellule)
NbCellVide = WorksheetFunction.CountBlank(Range(Cells(7, 4), Cells(2000, 4)))
Range("C6") = 1994 - NbCellVide
Nbligne = Range("C6")
'effacement des données pour calcul Colonne I,J,L,M,N,O
Range("I7:J" & Nbligne+6).ClearContents
Range("L7:O" & Nbligne+6).ClearContents
'Variable i va successivement prendre la valeur jusqu' a Derncellule vide + 6
For i = 7 To Nbligne + 6
'Ecrit dans la plage de cellules I (Affectation de la périodicité pour le calcul) et
'Ecrit dans la plage de cellules J (Affectation de la base d'arlerte pour le calcul)
If Cells(i, 8) = "D" And Cells(i, 7) = "Quotidien" Then
Cells(i, 9) = "1"
Cells(i, 10) = "1"
End If
If Cells(i, 8) = "D" And Cells(i, 7) = "Bihebdomadaire" Then
Cells(i, 9) = "3"
Cells(i, 10) = "0.99"
End If
If Cells(i, 8) = "D" And Cells(i, 7) = "Hebdomadaire" Then
Cells(i, 9) = "7"
Cells(i, 10) = "0.85"
End If
If Cells(i, 8) = "D" And Cells(i, 7) = "Mensuel" Then
Cells(i, 9) = "30"
Cells(i, 10) = "0.85"
End If
If Cells(i, 8) = "D" And Cells(i, 7) = "Bimestriel" Then
Cells(i, 9) = "61"
Cells(i, 10) = "0.85"
End If
If Cells(i, 8) = "D" And Cells(i, 7) = "Trimestriel" Then
Cells(i, 9) = "91"
Cells(i, 10) = "0.85"
End If
If Cells(i, 8) = "D" And Cells(i, 7) = "Semestriel" Then
Cells(i, 9) = "183"
Cells(i, 10) = "0.85"
End If
If Cells(i, 8) = "D" And Cells(i, 7) = "Annuel" Then
Cells(i, 9) = "365"
Cells(i, 10) = "0.85"
End If
If Cells(i, 8) = "D" And Cells(i, 7) = "Bisannuel" Then
Cells(i, 9) = "730"
Cells(i, 10) = "0.85"
End If
If Cells(i, 8) = "D" And Cells(i, 7) = "Triennal" Then
Cells(i, 9) = "1096"
Cells(i, 10) = "0.85"
End If
If Cells(i, 8) = "D" And Cells(i, 7) = "Quadiennal" Then
Cells(i, 9) = "1461"
Cells(i, 10) = "0.85"
End If
If Cells(i, 8) = "D" And Cells(i, 7) = "Quinquennal" Then
Cells(i, 9) = "1826"
Cells(i, 10) = "0.85"
End If
If Cells(i, 8) = "C" Then
Cells(i, 9) = Cells(i, 7)
Cells(i, 10) = "0.95"
End If
Next i
End Sub
Code:
Private Sub ComboBox2_Change()
'
'Affectation du Label en fonction du Combo
If ComboBox2 = "Quotidien" Then Label7 = "qui a lieu une fois par jours"
If ComboBox2 = "Bihebdomadaire" Then Label7 = "qui a lieu deux fois par semaine"
If ComboBox2 = "Hebdomadaire" Then Label7 = "qui a lieu une fois par semaine"
If ComboBox2 = "Mensuel" Then Label7 = "qui a lieu une fois par mois"
If ComboBox2 = "Bimestriel" Then Label7 = "qui a lieu tous les deux mois"
If ComboBox2 = "Trimestriel" Then Label7 = "qui a lieu tous les trois mois"
If ComboBox2 = "Semestriel" Then Label7 = "qui a lieu tous les six mois"
If ComboBox2 = "Annuel" Then Label7 = "qui a lieu une fois par an"
If ComboBox2 = "Bisannuel" Then Label7 = "qui a lieu tous les deux ans"
If ComboBox2 = "Triennal" Then Label7 = "qui a lieu tous les trois ans"
If ComboBox2 = "Quadiennal" Then Label7 = "qui a lieu tous les quatre ans"
If ComboBox2 = "Quinquennal" Then Label7 = "qui a lieu tous les cinq ans"
If ComboBox2 = "" Then Label7 = ""
End Sub
Je vous en remercie par avance de vos reponses.
Cordialement