Faire une boucle de cellules
crimoilefort
-
Le Pingou Messages postés 12720 Date d'inscription Statut Contributeur Dernière intervention -
Le Pingou Messages postés 12720 Date d'inscription Statut Contributeur Dernière intervention -
Bonjour à vous tous,
Je voudrai effectuer une boucle de programme pour m'éviter de taper trop de lignes (je suis novice) --> je calcule le nombre de cellules d'une certaine couleur en fonction de son contenu :
Voici mon code (excel 2003):
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim a, b, c, d, e, f, g, h, i, j, k, m, n, o, p, q, r As Range
Dim mon_0, mon_1, mon_2, mon_3, mon_4, mon_5, mon_6, mon_7, mon_8, mon_9, mon_10, mon_11, mon_12, mon_13, mon_14, mon_15, mon_16, mon_17, mon_18 As Double
Application.Volatile True
For Each a In [x10:Cd10]
If a = [C9] And a.Interior.ColorIndex = [C9].Interior.ColorIndex Then
mon_0 = mon_0 + 1
End If
Next
[c10] = mon_0
For Each b In [x11:Cd11]
If b = [C9] And b.Interior.ColorIndex = [C9].Interior.ColorIndex Then
mon_1 = mon_1 + 1
End If
Next
[c11] = mon_1
For Each c In [x12:Cd12]
If c = [C9] And c.Interior.ColorIndex = [C9].Interior.ColorIndex Then
mon_2 = mon_2 + 1
End If
Next
End Sub
En fait, je voudrai reconduire ma premiére boucle "FOR" sur 31 lignes et sur 18 colonnes (tableau).
Merci pour vos réponses.
@+
crimoilefort
Je voudrai effectuer une boucle de programme pour m'éviter de taper trop de lignes (je suis novice) --> je calcule le nombre de cellules d'une certaine couleur en fonction de son contenu :
Voici mon code (excel 2003):
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim a, b, c, d, e, f, g, h, i, j, k, m, n, o, p, q, r As Range
Dim mon_0, mon_1, mon_2, mon_3, mon_4, mon_5, mon_6, mon_7, mon_8, mon_9, mon_10, mon_11, mon_12, mon_13, mon_14, mon_15, mon_16, mon_17, mon_18 As Double
Application.Volatile True
For Each a In [x10:Cd10]
If a = [C9] And a.Interior.ColorIndex = [C9].Interior.ColorIndex Then
mon_0 = mon_0 + 1
End If
Next
[c10] = mon_0
For Each b In [x11:Cd11]
If b = [C9] And b.Interior.ColorIndex = [C9].Interior.ColorIndex Then
mon_1 = mon_1 + 1
End If
Next
[c11] = mon_1
For Each c In [x12:Cd12]
If c = [C9] And c.Interior.ColorIndex = [C9].Interior.ColorIndex Then
mon_2 = mon_2 + 1
End If
Next
End Sub
En fait, je voudrai reconduire ma premiére boucle "FOR" sur 31 lignes et sur 18 colonnes (tableau).
Merci pour vos réponses.
@+
crimoilefort
A voir également:
- Faire une boucle de cellules
- Somme de plusieurs cellules excel - Guide
- Verrouiller cellules excel - Guide
- Fusionner deux cellules excel - Guide
- Afficher cellules masquées excel - Forum Excel
- Pour ce faire la taille des cellules fusionnées doit être identique ✓ - Forum Excel