Bonjour Tout le monde
J'ai voulu changer des boucles For next imbriquées en With - End With mais
ces dernières s'y perdent, la méthode find next ne fonctionne pas ,le code
d'erreur est 91.Dois je revenir au For ou ai je une erreur dans le code?
With bloc 'Plage en Feuil1
Set c = .Find(parcelle, LookIn:=xlValue)
If Not c Is Nothing Then
adr = c.Address
Do
If Sheets("Feuil1").Cells(c.Row, 20) = campa Then
se = se + 2
lg = c.Row
coef = Sheets("feuil1").Cells(lg, 15)
Set lign = Sheets("feuil1").Range("U" & lg & ":II" & lg)
sd = 0
' recherche de valeur sur une ligne en
Feuil1
With lign
Set d = .Find("*", LookIn:=xlValue)
If Not d Is Nothing Then
adr2 = d.Address
dc = d.Column
Do
sd = sd + 2
If (d * coef) > 0 Then
prod = Sheets("feuil1").Cells(36, dc)
' recherche des prix des
prod en sheet("Stocks")
With Sheets("Stocks").Range("A5:A225")
Set e = .Find(prod, LookIn:=xlValues)
If Not e Is Nothing Then
lgn = e.Row
prx =
Sheets("Stocks").Cells(lgn, O_i + 14)
End If
If Sheets("Stocks").Range("B" &
lgn) = "E" Or Sheets("Stocks").Range("B" & lgn) = "A" Then
If
IsNumeric(Sheets("Tableaux").Range("Engrais2").Find(prod,
LookIn:=xlValues).Offset(0, 6).Value) Then
' Rech Teneur N
val_N =
Sheets("Tableaux").Range("Engrais2").Find(prod, LookIn:=xlValues).Offset(0,
6).Value
End If
End If
End With
Cells(se - 1, sd) = prod
Cells(se, sd) = (d * coef)
Cells(se, sd).NumberFormat =
"#,##0.00"
Cells(se, 14) = Cells(se, 14) + (d *
coef * prx)
val_N1 = val_N1 + val_N * coef * d
val_N = 0
If prx = 0 Then
Cells(se, sd + 1).Font.ColorIndex =
3
Cells(se, sd + 1) = "prix?"
Else
Cells(se, sd + 1).Font.ColorIndex =
xlAutomatic
Cells(se, sd + 1) = prx
End If
End If
Cells(se, 1) = Sheets("feuil1").Cells(lg, 1)
Cells(se - 1, 1) = "N°:" &
Sheets("feuil1").Cells(lg, 2)
Sheets("feuil1").Range(d.Address).Activate
Set d = .FindNext(d)
Loop While Not d Is Nothing And d.Address <>
adr2 ' le saut se fait ici vers gesterr:
End If
End With
End If
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address <> adr
End If
End With
Cette action est irreversible, confirmez la suppression du commentaire ?
Signaler le commentaire
Veuillez sélectionner un problème
Nudité
Violence
Harcèlement
Fraude
Vente illégale
Discours haineux
Terrorisme
Autre
Ellimac
Bonjour,
A ma connaissance l'instruction With n'est pas une boucle mais elle est plutôt destinée à éviter la répétition de l'élément qui la suit dans une suite d'instructions jusqu'au End With. Si tu veux une boucle il te faut remettrre des For ... Next.
Camille
-----Message d'origine----- Bonjour Tout le monde J'ai voulu changer des boucles For next imbriquées en With - End With mais
ces dernières s'y perdent, la méthode find next ne fonctionne pas ,le code
d'erreur est 91.Dois je revenir au For ou ai je une erreur dans le code?
With bloc 'Plage en Feuil1 Set c = .Find(parcelle, LookIn:=xlValue) If Not c Is Nothing Then adr = c.Address Do If Sheets("Feuil1").Cells(c.Row, 20) = campa Then se = se + 2 lg = c.Row coef = Sheets("feuil1").Cells(lg, 15) Set lign = Sheets("feuil1").Range("U" & lg & ":II" & lg)
sd = 0 ' recherche de valeur sur une ligne en
Feuil1 With lign Set d = .Find("*", LookIn:=xlValue) If Not d Is Nothing Then adr2 = d.Address dc = d.Column Do sd = sd + 2 If (d * coef) > 0 Then prod = Sheets ("feuil1").Cells(36, dc)
' recherche des prix des
prod en sheet("Stocks") With Sheets ("Stocks").Range("A5:A225")
Set e = .Find (prod, LookIn:=xlValues)
If Not e Is Nothing Then
lgn = e.Row prx = Sheets("Stocks").Cells(lgn, O_i + 14) End If If Sheets ("Stocks").Range("B" &
lgn) = "E" Or Sheets("Stocks").Range("B" & lgn) = "A" Then If IsNumeric(Sheets("Tableaux").Range("Engrais2").Find(prod, LookIn:=xlValues).Offset(0, 6).Value) Then
Set d = .FindNext(d) Loop While Not d Is Nothing And d.Address <>
adr2 ' le saut se fait ici vers gesterr: End If End With End If Set c = .FindNext(c) Loop While Not c Is Nothing And c.Address <> adr End If End With
-- Fred
.
Bonjour,
A ma connaissance l'instruction With n'est pas une boucle
mais elle est plutôt destinée à éviter la répétition de
l'élément qui la suit dans une suite d'instructions
jusqu'au End With.
Si tu veux une boucle il te faut remettrre des For ...
Next.
Camille
-----Message d'origine-----
Bonjour Tout le monde
J'ai voulu changer des boucles For next imbriquées en
With - End With mais
ces dernières s'y perdent, la méthode find next ne
fonctionne pas ,le code
d'erreur est 91.Dois je revenir au For ou ai je une
erreur dans le code?
With bloc 'Plage en Feuil1
Set c = .Find(parcelle, LookIn:=xlValue)
If Not c Is Nothing Then
adr = c.Address
Do
If Sheets("Feuil1").Cells(c.Row, 20) = campa Then
se = se + 2
lg = c.Row
coef = Sheets("feuil1").Cells(lg, 15)
Set lign = Sheets("feuil1").Range("U" & lg
& ":II" & lg)
sd = 0
' recherche de valeur sur
une ligne en
Feuil1
With lign
Set d = .Find("*", LookIn:=xlValue)
If Not d Is Nothing Then
adr2 = d.Address
dc = d.Column
Do
sd = sd + 2
If (d * coef) > 0 Then
prod = Sheets
("feuil1").Cells(36, dc)
'
recherche des prix des
prod en sheet("Stocks")
With Sheets
("Stocks").Range("A5:A225")
Set e = .Find
(prod, LookIn:=xlValues)
If Not e Is
Nothing Then
lgn = e.Row
prx =
Sheets("Stocks").Cells(lgn, O_i + 14)
End If
If Sheets
("Stocks").Range("B" &
lgn) = "E" Or Sheets("Stocks").Range("B" & lgn) = "A" Then
If
IsNumeric(Sheets("Tableaux").Range("Engrais2").Find(prod,
LookIn:=xlValues).Offset(0, 6).Value) Then
A ma connaissance l'instruction With n'est pas une boucle mais elle est plutôt destinée à éviter la répétition de l'élément qui la suit dans une suite d'instructions jusqu'au End With. Si tu veux une boucle il te faut remettrre des For ... Next.
Camille
-----Message d'origine----- Bonjour Tout le monde J'ai voulu changer des boucles For next imbriquées en With - End With mais
ces dernières s'y perdent, la méthode find next ne fonctionne pas ,le code
d'erreur est 91.Dois je revenir au For ou ai je une erreur dans le code?
With bloc 'Plage en Feuil1 Set c = .Find(parcelle, LookIn:=xlValue) If Not c Is Nothing Then adr = c.Address Do If Sheets("Feuil1").Cells(c.Row, 20) = campa Then se = se + 2 lg = c.Row coef = Sheets("feuil1").Cells(lg, 15) Set lign = Sheets("feuil1").Range("U" & lg & ":II" & lg)
sd = 0 ' recherche de valeur sur une ligne en
Feuil1 With lign Set d = .Find("*", LookIn:=xlValue) If Not d Is Nothing Then adr2 = d.Address dc = d.Column Do sd = sd + 2 If (d * coef) > 0 Then prod = Sheets ("feuil1").Cells(36, dc)
' recherche des prix des
prod en sheet("Stocks") With Sheets ("Stocks").Range("A5:A225")
Set e = .Find (prod, LookIn:=xlValues)
If Not e Is Nothing Then
lgn = e.Row prx = Sheets("Stocks").Cells(lgn, O_i + 14) End If If Sheets ("Stocks").Range("B" &
lgn) = "E" Or Sheets("Stocks").Range("B" & lgn) = "A" Then If IsNumeric(Sheets("Tableaux").Range("Engrais2").Find(prod, LookIn:=xlValues).Offset(0, 6).Value) Then
Set d = .FindNext(d) Loop While Not d Is Nothing And d.Address <>
adr2 ' le saut se fait ici vers gesterr: End If End With End If Set c = .FindNext(c) Loop While Not c Is Nothing And c.Address <> adr End If End With
-- Fred
.
Frédo P.
"Ellimac" a écrit dans le message de news: 0ab201c3a52c$9e9cdc10$ Bonjour,
A ma connaissance l'instruction With n'est pas une boucle mais elle est plutôt destinée à éviter la répétition de l'élément qui la suit dans une suite d'instructions jusqu'au End With. Si tu veux une boucle il te faut remettrre des For ... Next.
Camille Ah! je vois que le post est trop gros >4kg Le do _ loop à l'intérieur ?? merci Camille
-----Message d'origine----- Bonjour Tout le monde J'ai voulu changer des boucles For next imbriquées en With - End With mais
ces dernières s'y perdent, la méthode find next ne fonctionne pas ,le code
d'erreur est 91.Dois je revenir au For ou ai je une erreur dans le code?
With bloc 'Plage en Feuil1 Set c = .Find(parcelle, LookIn:=xlValue) If Not c Is Nothing Then adr = c.Address Do If Sheets("Feuil1").Cells(c.Row, 20) = campa Then se = se + 2 lg = c.Row coef = Sheets("feuil1").Cells(lg, 15) Set lign = Sheets("feuil1").Range("U" & lg & ":II" & lg)
sd = 0 ' recherche de valeur sur une ligne en
Feuil1 With lign Set d = .Find("*", LookIn:=xlValue) If Not d Is Nothing Then adr2 = d.Address dc = d.Column Do sd = sd + 2 If (d * coef) > 0 Then prod = Sheets ("feuil1").Cells(36, dc)
' recherche des prix des
prod en sheet("Stocks") With Sheets ("Stocks").Range("A5:A225")
Set e = .Find (prod, LookIn:=xlValues)
If Not e Is Nothing Then
lgn = e.Row prx >Sheets("Stocks").Cells(lgn, O_i + 14) End If If Sheets ("Stocks").Range("B" &
lgn) = "E" Or Sheets("Stocks").Range("B" & lgn) = "A" Then If IsNumeric(Sheets("Tableaux").Range("Engrais2").Find(prod, LookIn:=xlValues).Offset(0, 6).Value) Then
Set d = .FindNext(d) Loop While Not d Is Nothing And d.Address <>
adr2 ' le saut se fait ici vers gesterr: End If End With End If Set c = .FindNext(c) Loop While Not c Is Nothing And c.Address <> adr End If End With
-- Fred
.
"Ellimac" <anonymous@discussions.microsoft.com> a écrit dans le message de
news: 0ab201c3a52c$9e9cdc10$a301280a@phx.gbl...
Bonjour,
A ma connaissance l'instruction With n'est pas une boucle
mais elle est plutôt destinée à éviter la répétition de
l'élément qui la suit dans une suite d'instructions
jusqu'au End With.
Si tu veux une boucle il te faut remettrre des For ...
Next.
Camille
Ah! je vois que le post est trop gros >4kg
Le do _ loop à l'intérieur ??
merci Camille
-----Message d'origine-----
Bonjour Tout le monde
J'ai voulu changer des boucles For next imbriquées en
With - End With mais
ces dernières s'y perdent, la méthode find next ne
fonctionne pas ,le code
d'erreur est 91.Dois je revenir au For ou ai je une
erreur dans le code?
With bloc 'Plage en Feuil1
Set c = .Find(parcelle, LookIn:=xlValue)
If Not c Is Nothing Then
adr = c.Address
Do
If Sheets("Feuil1").Cells(c.Row, 20) = campa Then
se = se + 2
lg = c.Row
coef = Sheets("feuil1").Cells(lg, 15)
Set lign = Sheets("feuil1").Range("U" & lg
& ":II" & lg)
sd = 0
' recherche de valeur sur
une ligne en
Feuil1
With lign
Set d = .Find("*", LookIn:=xlValue)
If Not d Is Nothing Then
adr2 = d.Address
dc = d.Column
Do
sd = sd + 2
If (d * coef) > 0 Then
prod = Sheets
("feuil1").Cells(36, dc)
'
recherche des prix des
prod en sheet("Stocks")
With Sheets
("Stocks").Range("A5:A225")
Set e = .Find
(prod, LookIn:=xlValues)
If Not e Is
Nothing Then
lgn = e.Row
prx >Sheets("Stocks").Cells(lgn, O_i + 14)
End If
If Sheets
("Stocks").Range("B" &
lgn) = "E" Or Sheets("Stocks").Range("B" & lgn) = "A" Then
If
IsNumeric(Sheets("Tableaux").Range("Engrais2").Find(prod,
LookIn:=xlValues).Offset(0, 6).Value) Then
"Ellimac" a écrit dans le message de news: 0ab201c3a52c$9e9cdc10$ Bonjour,
A ma connaissance l'instruction With n'est pas une boucle mais elle est plutôt destinée à éviter la répétition de l'élément qui la suit dans une suite d'instructions jusqu'au End With. Si tu veux une boucle il te faut remettrre des For ... Next.
Camille Ah! je vois que le post est trop gros >4kg Le do _ loop à l'intérieur ?? merci Camille
-----Message d'origine----- Bonjour Tout le monde J'ai voulu changer des boucles For next imbriquées en With - End With mais
ces dernières s'y perdent, la méthode find next ne fonctionne pas ,le code
d'erreur est 91.Dois je revenir au For ou ai je une erreur dans le code?
With bloc 'Plage en Feuil1 Set c = .Find(parcelle, LookIn:=xlValue) If Not c Is Nothing Then adr = c.Address Do If Sheets("Feuil1").Cells(c.Row, 20) = campa Then se = se + 2 lg = c.Row coef = Sheets("feuil1").Cells(lg, 15) Set lign = Sheets("feuil1").Range("U" & lg & ":II" & lg)
sd = 0 ' recherche de valeur sur une ligne en
Feuil1 With lign Set d = .Find("*", LookIn:=xlValue) If Not d Is Nothing Then adr2 = d.Address dc = d.Column Do sd = sd + 2 If (d * coef) > 0 Then prod = Sheets ("feuil1").Cells(36, dc)
' recherche des prix des
prod en sheet("Stocks") With Sheets ("Stocks").Range("A5:A225")
Set e = .Find (prod, LookIn:=xlValues)
If Not e Is Nothing Then
lgn = e.Row prx >Sheets("Stocks").Cells(lgn, O_i + 14) End If If Sheets ("Stocks").Range("B" &
lgn) = "E" Or Sheets("Stocks").Range("B" & lgn) = "A" Then If IsNumeric(Sheets("Tableaux").Range("Engrais2").Find(prod, LookIn:=xlValues).Offset(0, 6).Value) Then