Sélectionner chaque ligne avec une boucle
Résolu
Kuartz
Messages postés
852
Date d'inscription
Statut
Membre
Dernière intervention
-
Kuartz Messages postés 852 Date d'inscription Statut Membre Dernière intervention -
Kuartz Messages postés 852 Date d'inscription Statut Membre Dernière intervention -
Bonjour,
Voici mon code :
Il consiste à prendre chaque ligne et faire un encadré en bas et en haut (je ne veut pas les encadrés à droite et à gauche.
Mais il ne marche pas...
Merci.
Voici mon code :
Sub Macro1()
Dim WTF As Long, DERLI As Long
DERLI = Sheets(2).Range("A65536").End(xlUp).Row
For WTF = 4 To DERLI
Sheets(2).Range("A4" & WTF).Row.Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
Next WTF
End Sub
Il consiste à prendre chaque ligne et faire un encadré en bas et en haut (je ne veut pas les encadrés à droite et à gauche.
Mais il ne marche pas...
Merci.
3 réponses
-
Bonjour
Avec une boucleSub Macro1() Application.ScreenUpdating = False Dim WTF As Long, DERLI As Long DERLI = Sheets(2).Range("A65536").End(xlUp).Row For WTF = 4 To DERLI + 1 Sheets(2).Range("A" & WTF & ":D" & WTF).Select With Selection.Borders(xlEdgeTop) .LineStyle = xlContinuous .Weight = xlThin End With Next WTF End Sub
sans boucleSub Macro2() Application.ScreenUpdating = False Dim DERLI As Long DERLI = Sheets(2).Range("A65536").End(xlUp).Row Sheets(2).Range("A4:D" & DERLI).Select With Selection.Borders(xlEdgeTop) .LineStyle = xlContinuous .Weight = xlThin End With With Selection.Borders(xlEdgeTop) .LineStyle = xlContinuous .Weight = xlThin End With With Selection.Borders(xlInsideHorizontal) .LineStyle = xlContinuous .Weight = xlThin End With With Selection.Borders(xlEdgeBottom) .LineStyle = xlContinuous .Weight = xlThin End With End Sub
Ne connaissant pas les limites des colonnes, j'ai pris la colonne D comme dernière colonne, a vous de l'adapter
cdlt -
Merci beaucoup !
La sélection me posait problème...
Merci encore.
Cordialement, -
Bonjour,
la solution est facile mais tu m'as sérieusement déçu hier en ne daignant pas jeter un oeil sur la solution que je te proposais....
donc: ciao
-
J'ai mis le sujet en résolu hier car je suis sorti du travail et je ne suis pas retourné sur ccm. Comme le code marchait parfaitement, j'ai préféré le faire. Ca ne m'empêche pas du tout de lire ton code et de le tester en ce moment même. Je suis juste incapable de le comprendre, comme je l'ai expliqué dans le sujet en question.
-