ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   getting rid of selection for formatting (https://www.excelbanter.com/excel-programming/373756-getting-rid-selection-formatting.html)

Arnold Klapheck

getting rid of selection for formatting
 
I have been given code that seems repetative, was trying to figure out a way
to shorten it up and make more efficient. is there a way to refer to the
borders with one command. I was thinking of doing with within with
statements as follows

[***My Thoughts***]
With Range(A1:AQ1")
With .borders(xlEdgeLeft,wlEdgeTop, ..etc)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With .Font
.Name = "Arial"
.Size = 8
.Bold = False
.ColorIndex = xlAutomatic
End With
End With

[***The Code I need to modify***]
Range("A1:AQ1").Select
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
.NumberFormat = "General"
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
End With
With Selection.Font
.Name = "Arial"
.Size = 8
.Bold = False
.ColorIndex = xlAutomatic
End With
With Selection.Interior
.ColorIndex = 15
.Pattern = xlSolid
End With

Don Guillett

getting rid of selection for formatting
 
borderaround

--
Don Guillett
SalesAid Software

"Arnold Klapheck" wrote in
message ...
I have been given code that seems repetative, was trying to figure out a
way
to shorten it up and make more efficient. is there a way to refer to the
borders with one command. I was thinking of doing with within
with
statements as follows

[***My Thoughts***]
With Range(A1:AQ1")
With .borders(xlEdgeLeft,wlEdgeTop, ..etc)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With .Font
.Name = "Arial"
.Size = 8
.Bold = False
.ColorIndex = xlAutomatic
End With
End With

[***The Code I need to modify***]
Range("A1:AQ1").Select
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
.NumberFormat = "General"
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
End With
With Selection.Font
.Name = "Arial"
.Size = 8
.Bold = False
.ColorIndex = xlAutomatic
End With
With Selection.Interior
.ColorIndex = 15
.Pattern = xlSolid
End With





All times are GMT +1. The time now is 10:25 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com