Border formatting row of cells
On Friday, January 24, 2014 7:37:36 PM UTC-8, isabelle wrote:
hi Howard,
here is another example, hoping that this one might help you more
Sub test()
Dim lgn As Range
Dim i As Integer, y As Integer
Dim xledging
'xlEdgeLeft, xlEdgeRight, xlEdgeTop, xlEdgeBottom, xlInsideVertical,
xlInsideHorizontal, xlDiagonalUp, xlDiagonalDown
xledging = Array(xlEdgeLeft, xlEdgeRight, xlEdgeTop, xlEdgeBottom,
xlInsideVertical)
Set lgn = Application.InputBox(Prompt:= _
"Please select a row with your Mouse to be bolded.", _
Title:="SPECIFY ROW", Type:=8)
For i = 26 To 45 Step 2 ' column Z to column AS, , two cells at once
(Step 2)
For y = LBound(xledging) To UBound(xledging) ' 5 xledging 0 to 4
With Range(Cells(lgn.Row, i), Cells(lgn.Row, i + 1)).Borders(xledging(y))
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
If i = 26 And y = 0 Then .Weight = xlMedium ' test if is the first
cell and xlEdgeLeft
If i = 44 And y = 1 Then .Weight = xlMedium ' test if is the last
cell and xlEdgeRight
If y = 4 Then .Weight = xlHairline ' 4 = xlInsideVertical
End With
Next
Next
End Sub
isabelle
I really like the compactness of this, hope I can adapt it.
I copied to a standard module and ran it, selected a row from Z to AS on prompt and hit enter. Get a Type Mismatch on this line.
For y = LBound(xledging) To UBound(xledging) ' 5 xledging 0 to 4
Am I using the code correctly selecting Z to AS?
I have had some success in using the code I posted in the link, where I can make it skip the colored cells. But it is a bit quirky on the sheet with some kinks to iron out.
The code is waaaay long and a ton of With / End With and same with Selection. But it does run quite quickly.
Can you elaborate a bit on how and what I should do with your code.
Sure appreciate it.
Howard
|