pallu1234567890
Messages postés7Date d'inscriptionmercredi 11 juillet 2012StatutMembreDernière intervention12 juillet 2012
-
12 juil. 2012 à 09:32
LIBRE_MAX
Messages postés1402Date d'inscriptionmardi 1 mai 2007StatutMembreDernière intervention 7 octobre 2012
-
12 juil. 2012 à 12:09
bonjour je souhaite crée une macros comptant le nombre de fois ou apparaît une valeur numérique dans une plage de donnée, mais ça m'affiche le code erreur 1004 je comprend pas. Merci de vos réponse.
Public Sub calc()
Dim ligne As Single
Dim a As Single
ligne = 2
a = 0
Do While IsEmpty(Cells(igne, 3))
If Cells(ligne, 3) = 0.01 Then
a = a + 1
Else: ligne = ligne + 1
End If
Loop
Cells(2, 6) = a
pallu1234567890
Messages postés7Date d'inscriptionmercredi 11 juillet 2012StatutMembreDernière intervention12 juillet 2012 12 juil. 2012 à 11:01
c'est bon j'ai réussi enfaîte le ="0.01" fais tout planter du coup j'ai remplacer par ça mon code ( je 'ai avancé un peu). donc le calcul du nombre de cellule ayant les valeur numérique s'effectue parfaitement mais le calcul du total ( la variable g, dernier bloc) fait apparaître erreur 6 dépassement de capacité , une idée ?
Public Sub calc_0()
Dim ligne As Integer
Dim a As Integer
Dim b As Integer
Dim c As Integer
Dim d As Integer
Dim e As Integer
Dim f As Integer
Dim g As Integer
ligne = 2
a = 0
b = 0
c = 0
d = 0
e = 0
f = 0
g = 0
Do While Not IsEmpty(Cells(ligne, 1))
If Cells(ligne, 1) - Cells(ligne, 2) = 0 Then
a = a + 1
Else: a = a
End If
ligne = ligne + 1
Loop
Cells(3, 6) = a
ligne = 2
Do While Not IsEmpty(Cells(ligne, 1))
If Cells(ligne, 1) - Cells(ligne, 2) > 0 And Cells(ligne, 1) - Cells(ligne, 2) < 0.015 Then
b = b + 1
Else: b = b
End If
ligne = ligne + 1
Loop
Cells(3, 7) = b
ligne = 2
Do While Not IsEmpty(Cells(ligne, 1))
If Cells(ligne, 1) - Cells(ligne, 2) > 0.015 And Cells(ligne, 1) - Cells(ligne, 2) < 0.025 Then
c = c + 1
Else: c = c
End If
ligne = ligne + 1
Loop
Cells(3, 8) = c
ligne = 2
Do While Not IsEmpty(Cells(ligne, 1))
If Cells(ligne, 1) - Cells(ligne, 2) > 0.025 And Cells(ligne, 1) - Cells(ligne, 2) < 0.035 Then
d = d + 1
Else: d = d
End If
ligne = ligne + 1
Loop
Cells(3, 9) = d
ligne = 2
Do While Not IsEmpty(Cells(ligne, 1))
If Cells(ligne, 1) - Cells(ligne, 2) > 0.035 And Cells(ligne, 1) - Cells(ligne, 2) < 0.045 Then
e = e + 1
Else: e = e
End If
ligne = ligne + 1
Loop
Cells(3, 10) = e
ligne = 2
Do While Not IsEmpty(Cells(ligne, 1))
If Cells(ligne, 1) - Cells(ligne, 2) > 0.045 Then
f = f + 1
Else: f = f
End If
ligne = ligne + 1
Loop
Cells(3, 11) = f
ligne = 2
Do While Not IsEmpty(Cells(ligne, 1))
If Not IsEmpty(Cells(ligne, 1)) Then
g = g + 1
Else: g = g
End If
Loop
Cells(3, 5) = g
LIBRE_MAX
Messages postés1402Date d'inscriptionmardi 1 mai 2007StatutMembreDernière intervention 7 octobre 20126 12 juil. 2012 à 11:33
Do While Not IsEmpty(Cells(ligne, 1))
If Cells(ligne, 1) - Cells(ligne, 2) 0 Then a a + 1
If Cells(ligne, 1) - Cells(ligne, 2) > 0 And _
Cells(ligne, 1) - Cells(ligne, 2) < 0.015 Then b = b + 1
If Cells(ligne, 1) - Cells(ligne, 2) > 0.015 And _
Cells(ligne, 1) - Cells(ligne, 2) < 0.025 Then c = c + 1
'etc...
ligne = ligne + 1
Loop
Cells(3, 6) = a
Cells(3, 7) = b
Cells(3, 8) = c
'etc...