lorsque ma macro s'execute par le changement de valeur dans une
cellule, la boucle de la ligne 2 a 500 s'execute et ralenti mon
programme
ne pourrait-on pas executer la macro juste sur la ligne ou j'ai
modifi=E9 ma cellule
voici les codes
celui de la feuille
Private Sub Worksheet_Change(ByVal Target As Range)
'--------------------------
'- calcul de l'age -
'--------------------------
If Not Intersect([f2:f500], Target) Is Nothing Then
Call calcul_age
End If
End Sub
le code de la routine calcul_age
Sub calcul_age()
For i =3D 2 To ActiveSheet.Range("f500").End(xlUp).Row
Range("g" & i) =3D
"=3DIF(RC[-1]=3D"""","""",DATEDIF(RC[-1],TODAY(),""y""))"
Range("V" & i) =3D "=3DIF(AND(RC[-15]>1,RC[-15]<=3D50),""<
50"",IF(AND(RC[-15]>50,RC[-15]<100),""> 50"",""""))"
Range("aa" & i) =3D
"=3DIF(AND(RC[-4]=3D""X"",RC[-3]=3D""X"",RC[-2]=3D""X"",RC[-1]=3D""X""),""4
EP"","""")"
Next i
If Range("f" & i) =3D "" Then
Range("v" & i) =3D ""
Range("g" & i) =3D ""
End If
End Sub
donc en fait si je change une valeur dans la cellule F4 alors la
valeur de "i" dans ma routine prendra 4 au lieu de derouler de 2 a 500
Bonsoir, Si tu n'as besoin de recalculer que la ligne qui vient de changer, alors pas besoin de boucle ; tu pourrais t'y prendre ainsi :
Private Sub Worksheet_Change(ByVal Target As Range) '-------------------------- '- calcul de l'age - '-------------------------- If Not Intersect([f2:f500], Target) Is Nothing Then i = target.row Call calcul_age End If End Sub
Sub calcul_age()
Range("g" & i) "=IF(RC[-1]="""","""",DATEDIF(RC[-1],TODAY(),""y""))" Range("V" & i) = "=IF(AND(RC[-15]>1,RC[-15]<P),""< 50"",IF(AND(RC[-15]>50,RC[-15]<100),""> 50"",""""))" Range("aa" & i) "=IF(AND(RC[-4]=""X"",RC[-3]=""X"",RC[-2]=""X"",RC[-1]=""X""),""4 EP"","""")" If Range("f" & i) = "" Then Range("v" & i) = "" Range("g" & i) = "" End If
End Sub
-- Avec plaisir http://dj.joss.free.fr/trombine.htm http://jacxl.free.fr/mpfe/trombino.html Philippe.R Pour se connecter au forum : http://www.excelabo.net/mpfe/connexion.php News://news.microsoft.com/microsoft.public.fr.excel "magic-dd" a écrit dans le message de news: bonjour
j'ai un classeur avec 500 lignes
lorsque ma macro s'execute par le changement de valeur dans une cellule, la boucle de la ligne 2 a 500 s'execute et ralenti mon programme
ne pourrait-on pas executer la macro juste sur la ligne ou j'ai modifié ma cellule
voici les codes
celui de la feuille
Private Sub Worksheet_Change(ByVal Target As Range)
'-------------------------- '- calcul de l'age - '-------------------------- If Not Intersect([f2:f500], Target) Is Nothing Then Call calcul_age
End If
End Sub
le code de la routine calcul_age
Sub calcul_age()
For i = 2 To ActiveSheet.Range("f500").End(xlUp).Row Range("g" & i) "=IF(RC[-1]="""","""",DATEDIF(RC[-1],TODAY(),""y""))" Range("V" & i) = "=IF(AND(RC[-15]>1,RC[-15]<P),""< 50"",IF(AND(RC[-15]>50,RC[-15]<100),""> 50"",""""))" Range("aa" & i) "=IF(AND(RC[-4]=""X"",RC[-3]=""X"",RC[-2]=""X"",RC[-1]=""X""),""4 EP"","""")" Next i If Range("f" & i) = "" Then Range("v" & i) = "" Range("g" & i) = "" End If
End Sub
donc en fait si je change une valeur dans la cellule F4 alors la valeur de "i" dans ma routine prendra 4 au lieu de derouler de 2 a 500
merci
Bonsoir,
Si tu n'as besoin de recalculer que la ligne qui vient de changer, alors pas
besoin de boucle ; tu pourrais t'y prendre ainsi :
Private Sub Worksheet_Change(ByVal Target As Range)
'--------------------------
'- calcul de l'age -
'--------------------------
If Not Intersect([f2:f500], Target) Is Nothing Then
i = target.row
Call calcul_age
End If
End Sub
Sub calcul_age()
Range("g" & i) "=IF(RC[-1]="""","""",DATEDIF(RC[-1],TODAY(),""y""))"
Range("V" & i) = "=IF(AND(RC[-15]>1,RC[-15]<P),""<
50"",IF(AND(RC[-15]>50,RC[-15]<100),""> 50"",""""))"
Range("aa" & i) "=IF(AND(RC[-4]=""X"",RC[-3]=""X"",RC[-2]=""X"",RC[-1]=""X""),""4
EP"","""")"
If Range("f" & i) = "" Then
Range("v" & i) = ""
Range("g" & i) = ""
End If
End Sub
--
Avec plaisir
http://dj.joss.free.fr/trombine.htm
http://jacxl.free.fr/mpfe/trombino.html
Philippe.R
Pour se connecter au forum :
http://www.excelabo.net/mpfe/connexion.php
News://news.microsoft.com/microsoft.public.fr.excel
"magic-dd" <ciolandre@gmail.com> a écrit dans le message de
news:5bbed228-7d9a-4b0b-b0d8-1f6944bcc7e8@d45g2000hsc.googlegroups.com...
bonjour
j'ai un classeur avec 500 lignes
lorsque ma macro s'execute par le changement de valeur dans une
cellule, la boucle de la ligne 2 a 500 s'execute et ralenti mon
programme
ne pourrait-on pas executer la macro juste sur la ligne ou j'ai
modifié ma cellule
voici les codes
celui de la feuille
Private Sub Worksheet_Change(ByVal Target As Range)
'--------------------------
'- calcul de l'age -
'--------------------------
If Not Intersect([f2:f500], Target) Is Nothing Then
Call calcul_age
End If
End Sub
le code de la routine calcul_age
Sub calcul_age()
For i = 2 To ActiveSheet.Range("f500").End(xlUp).Row
Range("g" & i) "=IF(RC[-1]="""","""",DATEDIF(RC[-1],TODAY(),""y""))"
Range("V" & i) = "=IF(AND(RC[-15]>1,RC[-15]<P),""<
50"",IF(AND(RC[-15]>50,RC[-15]<100),""> 50"",""""))"
Range("aa" & i) "=IF(AND(RC[-4]=""X"",RC[-3]=""X"",RC[-2]=""X"",RC[-1]=""X""),""4
EP"","""")"
Next i
If Range("f" & i) = "" Then
Range("v" & i) = ""
Range("g" & i) = ""
End If
End Sub
donc en fait si je change une valeur dans la cellule F4 alors la
valeur de "i" dans ma routine prendra 4 au lieu de derouler de 2 a 500
Bonsoir, Si tu n'as besoin de recalculer que la ligne qui vient de changer, alors pas besoin de boucle ; tu pourrais t'y prendre ainsi :
Private Sub Worksheet_Change(ByVal Target As Range) '-------------------------- '- calcul de l'age - '-------------------------- If Not Intersect([f2:f500], Target) Is Nothing Then i = target.row Call calcul_age End If End Sub
Sub calcul_age()
Range("g" & i) "=IF(RC[-1]="""","""",DATEDIF(RC[-1],TODAY(),""y""))" Range("V" & i) = "=IF(AND(RC[-15]>1,RC[-15]<P),""< 50"",IF(AND(RC[-15]>50,RC[-15]<100),""> 50"",""""))" Range("aa" & i) "=IF(AND(RC[-4]=""X"",RC[-3]=""X"",RC[-2]=""X"",RC[-1]=""X""),""4 EP"","""")" If Range("f" & i) = "" Then Range("v" & i) = "" Range("g" & i) = "" End If
End Sub
-- Avec plaisir http://dj.joss.free.fr/trombine.htm http://jacxl.free.fr/mpfe/trombino.html Philippe.R Pour se connecter au forum : http://www.excelabo.net/mpfe/connexion.php News://news.microsoft.com/microsoft.public.fr.excel "magic-dd" a écrit dans le message de news: bonjour
j'ai un classeur avec 500 lignes
lorsque ma macro s'execute par le changement de valeur dans une cellule, la boucle de la ligne 2 a 500 s'execute et ralenti mon programme
ne pourrait-on pas executer la macro juste sur la ligne ou j'ai modifié ma cellule
voici les codes
celui de la feuille
Private Sub Worksheet_Change(ByVal Target As Range)
'-------------------------- '- calcul de l'age - '-------------------------- If Not Intersect([f2:f500], Target) Is Nothing Then Call calcul_age
End If
End Sub
le code de la routine calcul_age
Sub calcul_age()
For i = 2 To ActiveSheet.Range("f500").End(xlUp).Row Range("g" & i) "=IF(RC[-1]="""","""",DATEDIF(RC[-1],TODAY(),""y""))" Range("V" & i) = "=IF(AND(RC[-15]>1,RC[-15]<P),""< 50"",IF(AND(RC[-15]>50,RC[-15]<100),""> 50"",""""))" Range("aa" & i) "=IF(AND(RC[-4]=""X"",RC[-3]=""X"",RC[-2]=""X"",RC[-1]=""X""),""4 EP"","""")" Next i If Range("f" & i) = "" Then Range("v" & i) = "" Range("g" & i) = "" End If
End Sub
donc en fait si je change une valeur dans la cellule F4 alors la valeur de "i" dans ma routine prendra 4 au lieu de derouler de 2 a 500
merci
Fredo P
Private Sub Worksheet_Change(ByVal Target As Range)
'-------------------------- '- calcul de l'age - '-------------------------- Application.EnableEvents = False Application.ScreenUpdating = False If Not Intersect([f2:f500], Target) Is Nothing Then calcul_age (Target.Row)
End If Application.EnableEvents = True Application.ScreenUpdating = True End Sub
Sub calcul_age(Targ#) Range("g" & Targ) = "=IF(RC[-1]="""","""",DATEDIF(RC[-1],TODAY(),""y""))" Range("V" & Targ) = "=IF(AND(RC[-15]>1,RC[-15]<P),""<50"",IF(AND(RC[-15]>50,RC[-15]<100),""> 50"",""""))" Range("aa" & Targ) = "=IF(AND(RC[-4]=""X"",RC[-3]=""X"",RC[-2]=""X"",RC[-1]=""X""),""4EP"","""")" If Range("f" & Targ) = "" Then Range("v" & Targ) = "" Range("g" & Targ) = "" End If
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
'--------------------------
'- calcul de l'age -
'--------------------------
Application.EnableEvents = False
Application.ScreenUpdating = False
If Not Intersect([f2:f500], Target) Is Nothing Then
calcul_age (Target.Row)
End If
Application.EnableEvents = True
Application.ScreenUpdating = True
End Sub
Sub calcul_age(Targ#)
Range("g" & Targ) =
"=IF(RC[-1]="""","""",DATEDIF(RC[-1],TODAY(),""y""))"
Range("V" & Targ) =
"=IF(AND(RC[-15]>1,RC[-15]<P),""<50"",IF(AND(RC[-15]>50,RC[-15]<100),"">
50"",""""))"
Range("aa" & Targ) =
"=IF(AND(RC[-4]=""X"",RC[-3]=""X"",RC[-2]=""X"",RC[-1]=""X""),""4EP"","""")"
If Range("f" & Targ) = "" Then
Range("v" & Targ) = ""
Range("g" & Targ) = ""
End If
Private Sub Worksheet_Change(ByVal Target As Range)
'-------------------------- '- calcul de l'age - '-------------------------- Application.EnableEvents = False Application.ScreenUpdating = False If Not Intersect([f2:f500], Target) Is Nothing Then calcul_age (Target.Row)
End If Application.EnableEvents = True Application.ScreenUpdating = True End Sub
Sub calcul_age(Targ#) Range("g" & Targ) = "=IF(RC[-1]="""","""",DATEDIF(RC[-1],TODAY(),""y""))" Range("V" & Targ) = "=IF(AND(RC[-15]>1,RC[-15]<P),""<50"",IF(AND(RC[-15]>50,RC[-15]<100),""> 50"",""""))" Range("aa" & Targ) = "=IF(AND(RC[-4]=""X"",RC[-3]=""X"",RC[-2]=""X"",RC[-1]=""X""),""4EP"","""")" If Range("f" & Targ) = "" Then Range("v" & Targ) = "" Range("g" & Targ) = "" End If
End Sub
Fredo P
Un peu d'explication
Private Sub Worksheet_Change(ByVal Target As Range)
'-------------------------- '- calcul de l'age - '-------------------------- Application.EnableEvents = False 'ligne de commande qui aurait pu être ajouter à ta procédure originale pour une amélioration considérable de la vitesse d'éxécution, ne pas oublier de remettre à True en fin de procédure. Application.ScreenUpdating = False If Not Intersect([f2:f500], Target) Is Nothing Then calcul_age (Target.Row)
End If Application.EnableEvents = True ' Impératif Application.ScreenUpdating = True End Sub
Sub calcul_age(Targ#) Range("g" & Targ) = "=IF(RC[-1]="""","""",DATEDIF(RC[-1],TODAY(),""y""))" Range("V" & Targ) = "=IF(AND(RC[-15]>1,RC[-15]<P),""<50"",IF(AND(RC[-15]>50,RC[-15]<100),""> 50"",""""))" Range("aa" & Targ) = "=IF(AND(RC[-4]=""X"",RC[-3]=""X"",RC[-2]=""X"",RC[-1]=""X""),""4EP"","""")" If Range("f" & Targ) = "" Then Range("v" & Targ) = "" Range("g" & Targ) = "" End If
End Sub
Un peu d'explication
Private Sub Worksheet_Change(ByVal Target As Range)
'--------------------------
'- calcul de l'age -
'--------------------------
Application.EnableEvents = False 'ligne de commande qui
aurait pu être ajouter à ta procédure originale pour une amélioration
considérable de la vitesse d'éxécution, ne pas oublier de remettre à True en
fin de procédure.
Application.ScreenUpdating = False
If Not Intersect([f2:f500], Target) Is Nothing Then
calcul_age (Target.Row)
End If
Application.EnableEvents = True ' Impératif
Application.ScreenUpdating = True
End Sub
Sub calcul_age(Targ#)
Range("g" & Targ) =
"=IF(RC[-1]="""","""",DATEDIF(RC[-1],TODAY(),""y""))"
Range("V" & Targ) =
"=IF(AND(RC[-15]>1,RC[-15]<P),""<50"",IF(AND(RC[-15]>50,RC[-15]<100),"">
50"",""""))"
Range("aa" & Targ) =
"=IF(AND(RC[-4]=""X"",RC[-3]=""X"",RC[-2]=""X"",RC[-1]=""X""),""4EP"","""")"
If Range("f" & Targ) = "" Then
Range("v" & Targ) = ""
Range("g" & Targ) = ""
End If
Private Sub Worksheet_Change(ByVal Target As Range)
'-------------------------- '- calcul de l'age - '-------------------------- Application.EnableEvents = False 'ligne de commande qui aurait pu être ajouter à ta procédure originale pour une amélioration considérable de la vitesse d'éxécution, ne pas oublier de remettre à True en fin de procédure. Application.ScreenUpdating = False If Not Intersect([f2:f500], Target) Is Nothing Then calcul_age (Target.Row)
End If Application.EnableEvents = True ' Impératif Application.ScreenUpdating = True End Sub
Sub calcul_age(Targ#) Range("g" & Targ) = "=IF(RC[-1]="""","""",DATEDIF(RC[-1],TODAY(),""y""))" Range("V" & Targ) = "=IF(AND(RC[-15]>1,RC[-15]<P),""<50"",IF(AND(RC[-15]>50,RC[-15]<100),""> 50"",""""))" Range("aa" & Targ) = "=IF(AND(RC[-4]=""X"",RC[-3]=""X"",RC[-2]=""X"",RC[-1]=""X""),""4EP"","""")" If Range("f" & Targ) = "" Then Range("v" & Targ) = "" Range("g" & Targ) = "" End If
End Sub
Fredo P
Ho! la!! le i a perdu sa valeur en cours de route Philippe "Philippe.R" <AS_rauphil_chez_wanadoo.fr> a écrit dans le message de news:
Bonsoir, Si tu n'as besoin de recalculer que la ligne qui vient de changer, alors pas besoin de boucle ; tu pourrais t'y prendre ainsi :
Private Sub Worksheet_Change(ByVal Target As Range) '-------------------------- '- calcul de l'age - '-------------------------- If Not Intersect([f2:f500], Target) Is Nothing Then i = target.row Call calcul_age End If End Sub
Sub calcul_age()
Range("g" & i) > "=IF(RC[-1]="""","""",DATEDIF(RC[-1],TODAY(),""y""))" Range("V" & i) = "=IF(AND(RC[-15]>1,RC[-15]<P),""< 50"",IF(AND(RC[-15]>50,RC[-15]<100),""> 50"",""""))" Range("aa" & i) > "=IF(AND(RC[-4]=""X"",RC[-3]=""X"",RC[-2]=""X"",RC[-1]=""X""),""4 EP"","""")" If Range("f" & i) = "" Then Range("v" & i) = "" Range("g" & i) = "" End If
End Sub
-- Avec plaisir http://dj.joss.free.fr/trombine.htm http://jacxl.free.fr/mpfe/trombino.html Philippe.R Pour se connecter au forum : http://www.excelabo.net/mpfe/connexion.php News://news.microsoft.com/microsoft.public.fr.excel "magic-dd" a écrit dans le message de news: bonjour
j'ai un classeur avec 500 lignes
lorsque ma macro s'execute par le changement de valeur dans une cellule, la boucle de la ligne 2 a 500 s'execute et ralenti mon programme
ne pourrait-on pas executer la macro juste sur la ligne ou j'ai modifié ma cellule
voici les codes
celui de la feuille
Private Sub Worksheet_Change(ByVal Target As Range)
'-------------------------- '- calcul de l'age - '-------------------------- If Not Intersect([f2:f500], Target) Is Nothing Then Call calcul_age
End If
End Sub
le code de la routine calcul_age
Sub calcul_age()
For i = 2 To ActiveSheet.Range("f500").End(xlUp).Row Range("g" & i) > "=IF(RC[-1]="""","""",DATEDIF(RC[-1],TODAY(),""y""))" Range("V" & i) = "=IF(AND(RC[-15]>1,RC[-15]<P),""< 50"",IF(AND(RC[-15]>50,RC[-15]<100),""> 50"",""""))" Range("aa" & i) > "=IF(AND(RC[-4]=""X"",RC[-3]=""X"",RC[-2]=""X"",RC[-1]=""X""),""4 EP"","""")" Next i If Range("f" & i) = "" Then Range("v" & i) = "" Range("g" & i) = "" End If
End Sub
donc en fait si je change une valeur dans la cellule F4 alors la valeur de "i" dans ma routine prendra 4 au lieu de derouler de 2 a 500
merci
Ho! la!! le i a perdu sa valeur en cours de route Philippe
"Philippe.R" <AS_rauphil_chez_wanadoo.fr> a écrit dans le message de news:
eocw6wQ6IHA.5808@TK2MSFTNGP02.phx.gbl...
Bonsoir,
Si tu n'as besoin de recalculer que la ligne qui vient de changer, alors
pas besoin de boucle ; tu pourrais t'y prendre ainsi :
Private Sub Worksheet_Change(ByVal Target As Range)
'--------------------------
'- calcul de l'age -
'--------------------------
If Not Intersect([f2:f500], Target) Is Nothing Then
i = target.row
Call calcul_age
End If
End Sub
Sub calcul_age()
Range("g" & i) > "=IF(RC[-1]="""","""",DATEDIF(RC[-1],TODAY(),""y""))"
Range("V" & i) = "=IF(AND(RC[-15]>1,RC[-15]<P),""<
50"",IF(AND(RC[-15]>50,RC[-15]<100),""> 50"",""""))"
Range("aa" & i) > "=IF(AND(RC[-4]=""X"",RC[-3]=""X"",RC[-2]=""X"",RC[-1]=""X""),""4
EP"","""")"
If Range("f" & i) = "" Then
Range("v" & i) = ""
Range("g" & i) = ""
End If
End Sub
--
Avec plaisir
http://dj.joss.free.fr/trombine.htm
http://jacxl.free.fr/mpfe/trombino.html
Philippe.R
Pour se connecter au forum :
http://www.excelabo.net/mpfe/connexion.php
News://news.microsoft.com/microsoft.public.fr.excel
"magic-dd" <ciolandre@gmail.com> a écrit dans le message de
news:5bbed228-7d9a-4b0b-b0d8-1f6944bcc7e8@d45g2000hsc.googlegroups.com...
bonjour
j'ai un classeur avec 500 lignes
lorsque ma macro s'execute par le changement de valeur dans une
cellule, la boucle de la ligne 2 a 500 s'execute et ralenti mon
programme
ne pourrait-on pas executer la macro juste sur la ligne ou j'ai
modifié ma cellule
voici les codes
celui de la feuille
Private Sub Worksheet_Change(ByVal Target As Range)
'--------------------------
'- calcul de l'age -
'--------------------------
If Not Intersect([f2:f500], Target) Is Nothing Then
Call calcul_age
End If
End Sub
le code de la routine calcul_age
Sub calcul_age()
For i = 2 To ActiveSheet.Range("f500").End(xlUp).Row
Range("g" & i) > "=IF(RC[-1]="""","""",DATEDIF(RC[-1],TODAY(),""y""))"
Range("V" & i) = "=IF(AND(RC[-15]>1,RC[-15]<P),""<
50"",IF(AND(RC[-15]>50,RC[-15]<100),""> 50"",""""))"
Range("aa" & i) > "=IF(AND(RC[-4]=""X"",RC[-3]=""X"",RC[-2]=""X"",RC[-1]=""X""),""4
EP"","""")"
Next i
If Range("f" & i) = "" Then
Range("v" & i) = ""
Range("g" & i) = ""
End If
End Sub
donc en fait si je change une valeur dans la cellule F4 alors la
valeur de "i" dans ma routine prendra 4 au lieu de derouler de 2 a 500
Ho! la!! le i a perdu sa valeur en cours de route Philippe "Philippe.R" <AS_rauphil_chez_wanadoo.fr> a écrit dans le message de news:
Bonsoir, Si tu n'as besoin de recalculer que la ligne qui vient de changer, alors pas besoin de boucle ; tu pourrais t'y prendre ainsi :
Private Sub Worksheet_Change(ByVal Target As Range) '-------------------------- '- calcul de l'age - '-------------------------- If Not Intersect([f2:f500], Target) Is Nothing Then i = target.row Call calcul_age End If End Sub
Sub calcul_age()
Range("g" & i) > "=IF(RC[-1]="""","""",DATEDIF(RC[-1],TODAY(),""y""))" Range("V" & i) = "=IF(AND(RC[-15]>1,RC[-15]<P),""< 50"",IF(AND(RC[-15]>50,RC[-15]<100),""> 50"",""""))" Range("aa" & i) > "=IF(AND(RC[-4]=""X"",RC[-3]=""X"",RC[-2]=""X"",RC[-1]=""X""),""4 EP"","""")" If Range("f" & i) = "" Then Range("v" & i) = "" Range("g" & i) = "" End If
End Sub
-- Avec plaisir http://dj.joss.free.fr/trombine.htm http://jacxl.free.fr/mpfe/trombino.html Philippe.R Pour se connecter au forum : http://www.excelabo.net/mpfe/connexion.php News://news.microsoft.com/microsoft.public.fr.excel "magic-dd" a écrit dans le message de news: bonjour
j'ai un classeur avec 500 lignes
lorsque ma macro s'execute par le changement de valeur dans une cellule, la boucle de la ligne 2 a 500 s'execute et ralenti mon programme
ne pourrait-on pas executer la macro juste sur la ligne ou j'ai modifié ma cellule
voici les codes
celui de la feuille
Private Sub Worksheet_Change(ByVal Target As Range)
'-------------------------- '- calcul de l'age - '-------------------------- If Not Intersect([f2:f500], Target) Is Nothing Then Call calcul_age
End If
End Sub
le code de la routine calcul_age
Sub calcul_age()
For i = 2 To ActiveSheet.Range("f500").End(xlUp).Row Range("g" & i) > "=IF(RC[-1]="""","""",DATEDIF(RC[-1],TODAY(),""y""))" Range("V" & i) = "=IF(AND(RC[-15]>1,RC[-15]<P),""< 50"",IF(AND(RC[-15]>50,RC[-15]<100),""> 50"",""""))" Range("aa" & i) > "=IF(AND(RC[-4]=""X"",RC[-3]=""X"",RC[-2]=""X"",RC[-1]=""X""),""4 EP"","""")" Next i If Range("f" & i) = "" Then Range("v" & i) = "" Range("g" & i) = "" End If
End Sub
donc en fait si je change une valeur dans la cellule F4 alors la valeur de "i" dans ma routine prendra 4 au lieu de derouler de 2 a 500
merci
Philippe.R
Meuh non Fredo, ;o)) suffit de déclarer la variable publique en tête de module
Public i As Long
-- Avec plaisir http://dj.joss.free.fr/trombine.htm http://jacxl.free.fr/mpfe/trombino.html Philippe.R Pour se connecter au forum : http://www.excelabo.net/mpfe/connexion.php News://news.microsoft.com/microsoft.public.fr.excel "Fredo P" a écrit dans le message de news:
Ho! la!! le i a perdu sa valeur en cours de route Philippe "Philippe.R" <AS_rauphil_chez_wanadoo.fr> a écrit dans le message de news:
Bonsoir, Si tu n'as besoin de recalculer que la ligne qui vient de changer, alors pas besoin de boucle ; tu pourrais t'y prendre ainsi :
Private Sub Worksheet_Change(ByVal Target As Range) '-------------------------- '- calcul de l'age - '-------------------------- If Not Intersect([f2:f500], Target) Is Nothing Then i = target.row Call calcul_age End If End Sub
Sub calcul_age()
Range("g" & i) >> "=IF(RC[-1]="""","""",DATEDIF(RC[-1],TODAY(),""y""))" Range("V" & i) = "=IF(AND(RC[-15]>1,RC[-15]<P),""< 50"",IF(AND(RC[-15]>50,RC[-15]<100),""> 50"",""""))" Range("aa" & i) >> "=IF(AND(RC[-4]=""X"",RC[-3]=""X"",RC[-2]=""X"",RC[-1]=""X""),""4 EP"","""")" If Range("f" & i) = "" Then Range("v" & i) = "" Range("g" & i) = "" End If
End Sub
-- Avec plaisir http://dj.joss.free.fr/trombine.htm http://jacxl.free.fr/mpfe/trombino.html Philippe.R Pour se connecter au forum : http://www.excelabo.net/mpfe/connexion.php News://news.microsoft.com/microsoft.public.fr.excel "magic-dd" a écrit dans le message de news: bonjour
j'ai un classeur avec 500 lignes
lorsque ma macro s'execute par le changement de valeur dans une cellule, la boucle de la ligne 2 a 500 s'execute et ralenti mon programme
ne pourrait-on pas executer la macro juste sur la ligne ou j'ai modifié ma cellule
voici les codes
celui de la feuille
Private Sub Worksheet_Change(ByVal Target As Range)
'-------------------------- '- calcul de l'age - '-------------------------- If Not Intersect([f2:f500], Target) Is Nothing Then Call calcul_age
End If
End Sub
le code de la routine calcul_age
Sub calcul_age()
For i = 2 To ActiveSheet.Range("f500").End(xlUp).Row Range("g" & i) >> "=IF(RC[-1]="""","""",DATEDIF(RC[-1],TODAY(),""y""))" Range("V" & i) = "=IF(AND(RC[-15]>1,RC[-15]<P),""< 50"",IF(AND(RC[-15]>50,RC[-15]<100),""> 50"",""""))" Range("aa" & i) >> "=IF(AND(RC[-4]=""X"",RC[-3]=""X"",RC[-2]=""X"",RC[-1]=""X""),""4 EP"","""")" Next i If Range("f" & i) = "" Then Range("v" & i) = "" Range("g" & i) = "" End If
End Sub
donc en fait si je change une valeur dans la cellule F4 alors la valeur de "i" dans ma routine prendra 4 au lieu de derouler de 2 a 500
merci
Meuh non Fredo,
;o))
suffit de déclarer la variable publique en tête de module
Public i As Long
--
Avec plaisir
http://dj.joss.free.fr/trombine.htm
http://jacxl.free.fr/mpfe/trombino.html
Philippe.R
Pour se connecter au forum :
http://www.excelabo.net/mpfe/connexion.php
News://news.microsoft.com/microsoft.public.fr.excel
"Fredo P" <ponsinet.frederic363etdesbrouettes@orange.fr> a écrit dans le
message de news:Ov0vf6Q6IHA.3480@TK2MSFTNGP03.phx.gbl...
Ho! la!! le i a perdu sa valeur en cours de route Philippe
"Philippe.R" <AS_rauphil_chez_wanadoo.fr> a écrit dans le message de news:
eocw6wQ6IHA.5808@TK2MSFTNGP02.phx.gbl...
Bonsoir,
Si tu n'as besoin de recalculer que la ligne qui vient de changer, alors
pas besoin de boucle ; tu pourrais t'y prendre ainsi :
Private Sub Worksheet_Change(ByVal Target As Range)
'--------------------------
'- calcul de l'age -
'--------------------------
If Not Intersect([f2:f500], Target) Is Nothing Then
i = target.row
Call calcul_age
End If
End Sub
Sub calcul_age()
Range("g" & i) >> "=IF(RC[-1]="""","""",DATEDIF(RC[-1],TODAY(),""y""))"
Range("V" & i) = "=IF(AND(RC[-15]>1,RC[-15]<P),""<
50"",IF(AND(RC[-15]>50,RC[-15]<100),""> 50"",""""))"
Range("aa" & i) >> "=IF(AND(RC[-4]=""X"",RC[-3]=""X"",RC[-2]=""X"",RC[-1]=""X""),""4
EP"","""")"
If Range("f" & i) = "" Then
Range("v" & i) = ""
Range("g" & i) = ""
End If
End Sub
--
Avec plaisir
http://dj.joss.free.fr/trombine.htm
http://jacxl.free.fr/mpfe/trombino.html
Philippe.R
Pour se connecter au forum :
http://www.excelabo.net/mpfe/connexion.php
News://news.microsoft.com/microsoft.public.fr.excel
"magic-dd" <ciolandre@gmail.com> a écrit dans le message de
news:5bbed228-7d9a-4b0b-b0d8-1f6944bcc7e8@d45g2000hsc.googlegroups.com...
bonjour
j'ai un classeur avec 500 lignes
lorsque ma macro s'execute par le changement de valeur dans une
cellule, la boucle de la ligne 2 a 500 s'execute et ralenti mon
programme
ne pourrait-on pas executer la macro juste sur la ligne ou j'ai
modifié ma cellule
voici les codes
celui de la feuille
Private Sub Worksheet_Change(ByVal Target As Range)
'--------------------------
'- calcul de l'age -
'--------------------------
If Not Intersect([f2:f500], Target) Is Nothing Then
Call calcul_age
End If
End Sub
le code de la routine calcul_age
Sub calcul_age()
For i = 2 To ActiveSheet.Range("f500").End(xlUp).Row
Range("g" & i) >> "=IF(RC[-1]="""","""",DATEDIF(RC[-1],TODAY(),""y""))"
Range("V" & i) = "=IF(AND(RC[-15]>1,RC[-15]<P),""<
50"",IF(AND(RC[-15]>50,RC[-15]<100),""> 50"",""""))"
Range("aa" & i) >> "=IF(AND(RC[-4]=""X"",RC[-3]=""X"",RC[-2]=""X"",RC[-1]=""X""),""4
EP"","""")"
Next i
If Range("f" & i) = "" Then
Range("v" & i) = ""
Range("g" & i) = ""
End If
End Sub
donc en fait si je change une valeur dans la cellule F4 alors la
valeur de "i" dans ma routine prendra 4 au lieu de derouler de 2 a 500
Meuh non Fredo, ;o)) suffit de déclarer la variable publique en tête de module
Public i As Long
-- Avec plaisir http://dj.joss.free.fr/trombine.htm http://jacxl.free.fr/mpfe/trombino.html Philippe.R Pour se connecter au forum : http://www.excelabo.net/mpfe/connexion.php News://news.microsoft.com/microsoft.public.fr.excel "Fredo P" a écrit dans le message de news:
Ho! la!! le i a perdu sa valeur en cours de route Philippe "Philippe.R" <AS_rauphil_chez_wanadoo.fr> a écrit dans le message de news:
Bonsoir, Si tu n'as besoin de recalculer que la ligne qui vient de changer, alors pas besoin de boucle ; tu pourrais t'y prendre ainsi :
Private Sub Worksheet_Change(ByVal Target As Range) '-------------------------- '- calcul de l'age - '-------------------------- If Not Intersect([f2:f500], Target) Is Nothing Then i = target.row Call calcul_age End If End Sub
Sub calcul_age()
Range("g" & i) >> "=IF(RC[-1]="""","""",DATEDIF(RC[-1],TODAY(),""y""))" Range("V" & i) = "=IF(AND(RC[-15]>1,RC[-15]<P),""< 50"",IF(AND(RC[-15]>50,RC[-15]<100),""> 50"",""""))" Range("aa" & i) >> "=IF(AND(RC[-4]=""X"",RC[-3]=""X"",RC[-2]=""X"",RC[-1]=""X""),""4 EP"","""")" If Range("f" & i) = "" Then Range("v" & i) = "" Range("g" & i) = "" End If
End Sub
-- Avec plaisir http://dj.joss.free.fr/trombine.htm http://jacxl.free.fr/mpfe/trombino.html Philippe.R Pour se connecter au forum : http://www.excelabo.net/mpfe/connexion.php News://news.microsoft.com/microsoft.public.fr.excel "magic-dd" a écrit dans le message de news: bonjour
j'ai un classeur avec 500 lignes
lorsque ma macro s'execute par le changement de valeur dans une cellule, la boucle de la ligne 2 a 500 s'execute et ralenti mon programme
ne pourrait-on pas executer la macro juste sur la ligne ou j'ai modifié ma cellule
voici les codes
celui de la feuille
Private Sub Worksheet_Change(ByVal Target As Range)
'-------------------------- '- calcul de l'age - '-------------------------- If Not Intersect([f2:f500], Target) Is Nothing Then Call calcul_age
End If
End Sub
le code de la routine calcul_age
Sub calcul_age()
For i = 2 To ActiveSheet.Range("f500").End(xlUp).Row Range("g" & i) >> "=IF(RC[-1]="""","""",DATEDIF(RC[-1],TODAY(),""y""))" Range("V" & i) = "=IF(AND(RC[-15]>1,RC[-15]<P),""< 50"",IF(AND(RC[-15]>50,RC[-15]<100),""> 50"",""""))" Range("aa" & i) >> "=IF(AND(RC[-4]=""X"",RC[-3]=""X"",RC[-2]=""X"",RC[-1]=""X""),""4 EP"","""")" Next i If Range("f" & i) = "" Then Range("v" & i) = "" Range("g" & i) = "" End If
End Sub
donc en fait si je change une valeur dans la cellule F4 alors la valeur de "i" dans ma routine prendra 4 au lieu de derouler de 2 a 500
merci
magic-dd
merci pour cette rapidité mais j'en perds mon vba
je n'y comprends plus rien je ne sais pas ou mettre les procédures le targ# le i qui n'est plus la puis la déclaration i as long
donc je vous mets mon fichier
il y a très mais très certainement a simplifier
mais bon , je débute
merci de votre aide
http://cjoint.com/?hswNUSsevI
merci pour cette rapidité mais j'en perds mon vba
je n'y comprends plus rien
je ne sais pas ou mettre les procédures
le targ#
le i qui n'est plus la
puis la déclaration i as long
je n'y comprends plus rien je ne sais pas ou mettre les procédures le targ# le i qui n'est plus la puis la déclaration i as long
donc je vous mets mon fichier
il y a très mais très certainement a simplifier
mais bon , je débute
merci de votre aide
http://cjoint.com/?hswNUSsevI
Philippe.R
Bonsoir, En tête du module "categories" (juste avant "Sub categorie()") :
Public i As Long
et tu modifies ta macro calcul_age() en y retirant les lignes :
For i = 2 To ActiveSheet.Range("f500").End(xlUp).Row
et
Next i
Dans le module de Feuil1(CST), tu remplaces :
'-------------------------- '- calcul de l'age - '-------------------------- If Not Intersect([f2:f500], Target) Is Nothing Then Call calcul_age End If
par :
'-------------------------- '- calcul de l'age - '-------------------------- If Not Intersect([f2:f500], Target) Is Nothing Then i = Target.Row Call calcul_age End If
-- Avec plaisir http://dj.joss.free.fr/trombine.htm http://jacxl.free.fr/mpfe/trombino.html Philippe.R Pour se connecter au forum : http://www.excelabo.net/mpfe/connexion.php News://news.microsoft.com/microsoft.public.fr.excel "magic-dd" a écrit dans le message de news: merci pour cette rapidité mais j'en perds mon vba
je n'y comprends plus rien je ne sais pas ou mettre les procédures le targ# le i qui n'est plus la puis la déclaration i as long
donc je vous mets mon fichier
il y a très mais très certainement a simplifier
mais bon , je débute
merci de votre aide
http://cjoint.com/?hswNUSsevI
Bonsoir,
En tête du module "categories" (juste avant "Sub categorie()") :
Public i As Long
et tu modifies ta macro calcul_age() en y retirant les lignes :
For i = 2 To ActiveSheet.Range("f500").End(xlUp).Row
et
Next i
Dans le module de Feuil1(CST), tu remplaces :
'--------------------------
'- calcul de l'age -
'--------------------------
If Not Intersect([f2:f500], Target) Is Nothing Then
Call calcul_age
End If
par :
'--------------------------
'- calcul de l'age -
'--------------------------
If Not Intersect([f2:f500], Target) Is Nothing Then
i = Target.Row
Call calcul_age
End If
--
Avec plaisir
http://dj.joss.free.fr/trombine.htm
http://jacxl.free.fr/mpfe/trombino.html
Philippe.R
Pour se connecter au forum :
http://www.excelabo.net/mpfe/connexion.php
News://news.microsoft.com/microsoft.public.fr.excel
"magic-dd" <ciolandre@gmail.com> a écrit dans le message de
news:89cf6985-af7e-459e-92ba-cec2cc0ab4f7@z72g2000hsb.googlegroups.com...
merci pour cette rapidité mais j'en perds mon vba
je n'y comprends plus rien
je ne sais pas ou mettre les procédures
le targ#
le i qui n'est plus la
puis la déclaration i as long
Bonsoir, En tête du module "categories" (juste avant "Sub categorie()") :
Public i As Long
et tu modifies ta macro calcul_age() en y retirant les lignes :
For i = 2 To ActiveSheet.Range("f500").End(xlUp).Row
et
Next i
Dans le module de Feuil1(CST), tu remplaces :
'-------------------------- '- calcul de l'age - '-------------------------- If Not Intersect([f2:f500], Target) Is Nothing Then Call calcul_age End If
par :
'-------------------------- '- calcul de l'age - '-------------------------- If Not Intersect([f2:f500], Target) Is Nothing Then i = Target.Row Call calcul_age End If
-- Avec plaisir http://dj.joss.free.fr/trombine.htm http://jacxl.free.fr/mpfe/trombino.html Philippe.R Pour se connecter au forum : http://www.excelabo.net/mpfe/connexion.php News://news.microsoft.com/microsoft.public.fr.excel "magic-dd" a écrit dans le message de news: merci pour cette rapidité mais j'en perds mon vba
je n'y comprends plus rien je ne sais pas ou mettre les procédures le targ# le i qui n'est plus la puis la déclaration i as long
donc je vous mets mon fichier
il y a très mais très certainement a simplifier
mais bon , je débute
merci de votre aide
http://cjoint.com/?hswNUSsevI
Fredo P
"> suffit de déclarer la variable publique en tête de module
Public i As Long
Tu sauves la face la!!
"> suffit de déclarer la variable publique en tête de module
"> suffit de déclarer la variable publique en tête de module
Public i As Long
Tu sauves la face la!!
Fredo P
Attend Magic Tu mets celle ci dans le code de ta feuille
Private Sub Worksheet_Change(ByVal Target As Range) Application.EnableEvents = False If Not Intersect([f2:f500], Target) Is Nothing Then calcul_age (Target.Row) ' Le "Target. Row" =N° de ligne sera transmis à la procédure calcul_age dont la variable "i" prendra la valeur. End If Application.EnableEvents = True End Sub
Et celle ci dans un module, avec tout cela il n'y aura plus acune formule qui se posera dans tes cellules, mais seulement les résultats.
Sub calcul_age(i)
date1 = Format(Cells(i, 6), "mm/dd/yyyy") date2 = Format(Date, "mm/dd/yyyy") Range("g" & i) = Evaluate("DATEDIF(" & """" & date1 & """" & "," & """" & date2 & """" & "," & """Y""" & ")") If Range("W" & i) = "X" And Range("X" & i) = "X" And Range("Y" & i) = "X" And Range("Z" & i) = "X" Then Range("AA" & i) = "4 EP" End If If Range("G" & i) > 1 And Range("G" & i) < 50 Then Range("V" & i) = "<50" End If If Range("G" & i) > 50 And Range("G" & i) < 100 Then Range("V" & i) = ">50" End If If Range("f" & i) = "" Then Range("v" & i) = "" Range("g" & i) = "" End If
End Sub
Attend Magic
Tu mets celle ci dans le code de ta feuille
Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
If Not Intersect([f2:f500], Target) Is Nothing Then
calcul_age (Target.Row)
' Le "Target. Row" =N° de ligne sera transmis à la procédure calcul_age dont
la variable "i" prendra la valeur.
End If
Application.EnableEvents = True
End Sub
Et celle ci dans un module, avec tout cela il n'y aura plus acune formule
qui se posera dans tes cellules, mais seulement les résultats.
Sub calcul_age(i)
date1 = Format(Cells(i, 6), "mm/dd/yyyy")
date2 = Format(Date, "mm/dd/yyyy")
Range("g" & i) = Evaluate("DATEDIF(" & """" & date1 & """" & "," & """" &
date2 & """" & "," & """Y""" & ")")
If Range("W" & i) = "X" And Range("X" & i) = "X" And Range("Y" & i) = "X"
And Range("Z" & i) = "X" Then
Range("AA" & i) = "4 EP"
End If
If Range("G" & i) > 1 And Range("G" & i) < 50 Then
Range("V" & i) = "<50"
End If
If Range("G" & i) > 50 And Range("G" & i) < 100 Then
Range("V" & i) = ">50"
End If
If Range("f" & i) = "" Then
Range("v" & i) = ""
Range("g" & i) = ""
End If
Attend Magic Tu mets celle ci dans le code de ta feuille
Private Sub Worksheet_Change(ByVal Target As Range) Application.EnableEvents = False If Not Intersect([f2:f500], Target) Is Nothing Then calcul_age (Target.Row) ' Le "Target. Row" =N° de ligne sera transmis à la procédure calcul_age dont la variable "i" prendra la valeur. End If Application.EnableEvents = True End Sub
Et celle ci dans un module, avec tout cela il n'y aura plus acune formule qui se posera dans tes cellules, mais seulement les résultats.
Sub calcul_age(i)
date1 = Format(Cells(i, 6), "mm/dd/yyyy") date2 = Format(Date, "mm/dd/yyyy") Range("g" & i) = Evaluate("DATEDIF(" & """" & date1 & """" & "," & """" & date2 & """" & "," & """Y""" & ")") If Range("W" & i) = "X" And Range("X" & i) = "X" And Range("Y" & i) = "X" And Range("Z" & i) = "X" Then Range("AA" & i) = "4 EP" End If If Range("G" & i) > 1 And Range("G" & i) < 50 Then Range("V" & i) = "<50" End If If Range("G" & i) > 50 And Range("G" & i) < 100 Then Range("V" & i) = ">50" End If If Range("f" & i) = "" Then Range("v" & i) = "" Range("g" & i) = "" End If