Macro pour un bloc de cellules

bonjour,

je suis un novice en macro et hier on m'a aidé a réaliser un truc sympa qui m'a bien aidé ^^

voila, on m'a créé une macro pour ma première ligne sous cette forme :

Sub macro()

Do While Total <> -5

Calculate

valeur1 = Cells(2, 12) <= 0.7 And Cells(2, 12) >= 0.05 Or Cells(2, 12) = 0

valeur2 = Cells(2, 13) <= 0.7 And Cells(2, 13) >= 0.05 Or Cells(2, 13) = 0

valeur3 = Cells(2, 14) <= 0.7 And Cells(2, 14) >= 0.05 Or Cells(2, 14) = 0

valeur4 = Cells(2, 15) <= 0.7 And Cells(2, 15) >= 0.05 Or Cells(2, 15) = 0

valeur5 = Cells(2, 16) <= 0.7 And Cells(2, 16) >= 0.05 Or Cells(2, 16) = 0

Total = valeur1 + valeur2 + valeur3 + valeur4 + valeur5

Loop

End Sub

elle applique les conditions disons à mes cellules de L2 à P2!!

je voudrais savoir comment les appliques de L2 à P90 sans avoir à les taper pour chacune de mes cellules!! ^^

j'espère que mon message est compréhensible

Bonjour ,

Essaye ceci

Sub macro()

Dim total As Integer
Dim p As Integer

p = 2
total = 0

While p < 90
Calculate
valeur1 = Cells(p, 1) <= 0.7 And Cells(p, 1) >= 0.05 Or Cells(p, 1) = 0
valeur2 = Cells(p, 2) <= 0.7 And Cells(p, 2) >= 0.05 Or Cells(p, 2) = 0
valeur3 = Cells(p, 3) <= 0.7 And Cells(p, 3) >= 0.05 Or Cells(p, 3) = 0
valeur4 = Cells(p, 4) <= 0.7 And Cells(p, 4) >= 0.05 Or Cells(p, 4) = 0
valeur5 = Cells(p, 5) <= 0.7 And Cells(p, 5) >= 0.05 Or Cells(p, 5) = 0
total = total + valeur1 + valeur2 + valeur3 + valeur4 + valeur5
p = p + 1
Wend

End Sub

Cordialement

Rechercher des sujets similaires à "macro bloc"