-
Solved: Border Trouble!
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:
[vba]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[/vba] But it doesn't work. What am I doing wrong? This should be a fairly simple and straightforward step.
-
You neeed to pass the RN value to Border
EG
[VBA]
Sub DoThings()
Border 10
End Sub
Sub Border(RN As Long)
With Range("F" & RN)
.Borders(xlDiagonalDown).LineStyle = xlNone
'etc.
[/VBA]
MVP (Excel 2008-2010)
Post a workbook with sample data and layout if you want a quicker solution.
To help indent your macros try Smart Indent
Please remember to mark threads 'Solved'
-
I knew it was simple! Thanks for pointing that out
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules