Twitter iPhone pliant OnePlus 11 PS5 Disney+ Orange Livebox Windows 11

Erreur dans ma boucle

5 réponses
Avatar
Franck
Bonjour a tous,
j'ai le codage suivant

Range("A16").Select
Dim WS As Worksheet
For Each WS In Worksheets
If ActiveCell.FormulaR1C1 = "" Then Exit For
ActiveCell.Offset(0, 3).Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With

ActiveCell.Offset(0, 2).Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
ActiveCell.Offset(2, -5).Select
Next WS
End Sub

Quelqu'un ses pk quand il arrive a son troisieme Next WS il saute
automatiquement a mon end sub il ne recommence meme pas au début !
pourtant il devrait continuer 5 a 6 fois, car j'ai encord des choses
d'écrite dans mes cellules qui suivent

Merci de votre attention

5 réponses

Avatar
Daniel
Bonsoir.
Exit For te conduit à la première instruction après le Next, soit End Sub.
Cordialement.
Daniel
"Franck" a écrit dans le message de news:

Bonjour a tous,
j'ai le codage suivant

Range("A16").Select
Dim WS As Worksheet
For Each WS In Worksheets
If ActiveCell.FormulaR1C1 = "" Then Exit For
ActiveCell.Offset(0, 3).Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With

ActiveCell.Offset(0, 2).Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
ActiveCell.Offset(2, -5).Select
Next WS
End Sub

Quelqu'un ses pk quand il arrive a son troisieme Next WS il saute
automatiquement a mon end sub il ne recommence meme pas au début !
pourtant il devrait continuer 5 a 6 fois, car j'ai encord des choses
d'écrite dans mes cellules qui suivent

Merci de votre attention



Avatar
Franck
Bonsoir Daniel
ouais je ses qu'il me conduit a sa mais le probleme ses que If
ActiveCell.FormulaR1C1 = "" et bien il y a de quoi d'écrit dans ma cellule
active.
il en fait seulement 3 a chaque fois :(
il ne depasse jamais 3 boucle .... si je vais un pas a pas (f8) et bien a la
troisieme fois qu'il passe par dessus next WS il descent a end sub il
remonte meme pas au debut de for each ws......

merci
"Franck" a écrit dans le message de news:

Bonjour a tous,
j'ai le codage suivant

Range("A16").Select
Dim WS As Worksheet
For Each WS In Worksheets
If ActiveCell.FormulaR1C1 = "" Then Exit For
ActiveCell.Offset(0, 3).Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With

ActiveCell.Offset(0, 2).Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
ActiveCell.Offset(2, -5).Select
Next WS
End Sub

Quelqu'un ses pk quand il arrive a son troisieme Next WS il saute
automatiquement a mon end sub il ne recommence meme pas au début !
pourtant il devrait continuer 5 a 6 fois, car j'ai encord des choses
d'écrite dans mes cellules qui suivent

Merci de votre attention



Avatar
Daniel
Vérifie quand même que tu es bien sur la bonne feuille. A ta place,
j'ajouterais :
msgbox WS.Name
après For each...
Histoire d'être sûr.
Cordialement.
Daniel
"Franck" a écrit dans le message de news:
%
Bonsoir Daniel
ouais je ses qu'il me conduit a sa mais le probleme ses que If
ActiveCell.FormulaR1C1 = "" et bien il y a de quoi d'écrit dans ma
cellule
active.
il en fait seulement 3 a chaque fois :(
il ne depasse jamais 3 boucle .... si je vais un pas a pas (f8) et bien a
la
troisieme fois qu'il passe par dessus next WS il descent a end sub il
remonte meme pas au debut de for each ws......

merci
"Franck" a écrit dans le message de news:

Bonjour a tous,
j'ai le codage suivant

Range("A16").Select
Dim WS As Worksheet
For Each WS In Worksheets
If ActiveCell.FormulaR1C1 = "" Then Exit For
ActiveCell.Offset(0, 3).Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With

ActiveCell.Offset(0, 2).Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
ActiveCell.Offset(2, -5).Select
Next WS
End Sub

Quelqu'un ses pk quand il arrive a son troisieme Next WS il saute
automatiquement a mon end sub il ne recommence meme pas au début !
pourtant il devrait continuer 5 a 6 fois, car j'ai encord des choses
d'écrite dans mes cellules qui suivent

Merci de votre attention







Avatar
Lionel
Bonsoir Franck,

Sans plus chercher à savoir ce que tu souhaites faire avec ce code, je
dirais que tu ne travailles qu'avec les cellules de ta feuille active.
Est-ce vraiment ce que tu as voulu coder ? Car en aucun cas des cellules de
la feuille WS ne sont utilisées (???).

Amicalement
Lionel


"Franck" a écrit dans le message de
news:
Bonjour a tous,
j'ai le codage suivant

Range("A16").Select
Dim WS As Worksheet
For Each WS In Worksheets
If ActiveCell.FormulaR1C1 = "" Then Exit For
ActiveCell.Offset(0, 3).Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With

ActiveCell.Offset(0, 2).Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
ActiveCell.Offset(2, -5).Select
Next WS
End Sub

Quelqu'un ses pk quand il arrive a son troisieme Next WS il saute
automatiquement a mon end sub il ne recommence meme pas au début !
pourtant il devrait continuer 5 a 6 fois, car j'ai encord des choses
d'écrite dans mes cellules qui suivent

Merci de votre attention




Avatar
Franck
Bonjour a tous,
bons j'ai regler mon probleme je ses pas pk j'avais mit

Dim WS As Worksheet
For Each WS In Worksheets

au lieu de

Dim c As Range
For Each c In Range("A14", "F400")

j'etait dans les patate hier
Merci a tout pour votre aide :)


"Franck" a écrit dans le message de news:

Bonjour a tous,
j'ai le codage suivant

Range("A16").Select
Dim WS As Worksheet
For Each WS In Worksheets
If ActiveCell.FormulaR1C1 = "" Then Exit For
ActiveCell.Offset(0, 3).Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With

ActiveCell.Offset(0, 2).Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
ActiveCell.Offset(2, -5).Select
Next WS
End Sub

Quelqu'un ses pk quand il arrive a son troisieme Next WS il saute
automatiquement a mon end sub il ne recommence meme pas au début !
pourtant il devrait continuer 5 a 6 fois, car j'ai encord des choses
d'écrite dans mes cellules qui suivent

Merci de votre attention