poipoi
XLDnaute Impliqué
bonjour à tous
voilà j'ai une macro qui, en principe, met au format souhaiter directement une ou des cellules. Tout va bien quand je sélectionne une plage de cellules avec au moins 2 lignes mais sur une ligne ça me renvoie un messsage d'erreur, je pense que c'est parce que la macro considère qu'il n'y a pas de bordures à l'intérieur de la cellule..
voici le code:
For Each Cellule In Selection.Cells
With Selection.Interior
.ColorIndex = 11
.Pattern = xlSolid
End With
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 11
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 11
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 11
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 11
End With
With Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 2
End With
With Selection.Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 2
End With
With Selection.Interior
Selection.Font.ColorIndex = 2
Selection.Font.Bold = True
End With
Next
End Sub
d'avance merci à vous
voilà j'ai une macro qui, en principe, met au format souhaiter directement une ou des cellules. Tout va bien quand je sélectionne une plage de cellules avec au moins 2 lignes mais sur une ligne ça me renvoie un messsage d'erreur, je pense que c'est parce que la macro considère qu'il n'y a pas de bordures à l'intérieur de la cellule..
voici le code:
For Each Cellule In Selection.Cells
With Selection.Interior
.ColorIndex = 11
.Pattern = xlSolid
End With
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 11
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 11
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 11
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 11
End With
With Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 2
End With
With Selection.Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 2
End With
With Selection.Interior
Selection.Font.ColorIndex = 2
Selection.Font.Bold = True
End With
Next
End Sub
d'avance merci à vous