Bonjour à tous,
j'ai une petite macro très simple qui (en théorie) sélectionne certaines plages de mon tableau, leur met une couleur de fond blanche (elles sont grisées au départ) et leur donne une certaine bordure. Voila le code :
Sub Macro1()
Dim I As Integer
For I = 10 To 218 Step 8
Range(I & "8:" & I & "27").Select
Selection.Interior.ColorIndex = 2
slection.Font.Bold = False
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
Next I
End Sub
Mais quand je l'exécute ça me fait n'importe quoi, il sélectionne les lignes 200 à 2000 et quelques et applique le format voulu... j'ai sûrement dû me gourer au niveau du Range(I & "8:" & I & "27").Select pourtant je n'ai pas de messages d'erreur et sinon je ne vois pas comment faire... J'ai tenté un
Dim myrange as Range
set myrange = Range(I & "8:" & I & "27")
en remplaçant tous les "Selection" par "myrange" sans succès.
Merci de votre aide