PDA

View Full Version : Solved: Border Trouble!



compariniaa
06-28-2006, 01:42 PM
I recorded a macro to add a border all around the last cell in column F. After Adjusting it (RN is the row number of the last nonblank cell), this is what I came up with:

Sub Border()
With Range("F" & RN)
.borders(xlDiagonalDown).LineStyle = xlNone
.borders(xlDiagonalUp).LineStyle = xlNone
With .borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With .borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With .borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With .borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
End With
End Sub But it doesn't work. What am I doing wrong? This should be a fairly simple and straightforward step.

mdmackillop
06-28-2006, 02:01 PM
You neeed to pass the RN value to Border
EG

Sub DoThings()
Border 10
End Sub

Sub Border(RN As Long)
With Range("F" & RN)
.Borders(xlDiagonalDown).LineStyle = xlNone
'etc.

compariniaa
06-28-2006, 02:24 PM
I knew it was simple! Thanks for pointing that out