So I have a spreadsheet that is five columns wide. It's a daily log. At the end of a day, I like to add a bottom border to the cells that represent the activity of the day, to help me distinguish separate days. I recorded a macro that works on a separate cell, or a selection. What I want it to do is apply the border to five cells, after I select just one. What am I missing? Here's the code. Sub ApplyBorder() ' ' ApplyBorder Macro ' Applies bottom border to selected cells '
' Selection.Borders(xlDiagonalDown).LineStyle = xlNone Selection.Borders(xlDiagonalUp).LineStyle = xlNone Selection.Borders(xlEdgeLeft).LineStyle = xlNone Selection.Borders(xlEdgeTop).LineStyle = xlNone With Selection.Borders(xlEdgeBottom) .LineStyle = xlContinuous .ColorIndex = xlAutomatic .TintAndShade = 0 .Weight = xlMedium End With Selection.Borders(xlEdgeRight).LineStyle = xlNone Selection.Borders(xlInsideVertical).LineStyle = xlNone Selection.Borders(xlInsideHorizontal).LineStyle = xlNone End Sub
Reply from Alex Hedley:
I'll need to test this but would the tint and shade not need a value other than 0?
You can use some code to get the last row but this with the range changed should work. Range("A1:A2").Borders(xlEdgeBottom).LineStyle = xlContinuous
Sorry, only students may add comments.
Click here for more
information on how you can set up an account.
If you are a Visitor, go ahead and post your reply as a
new comment, and we'll move it here for you
once it's approved. Be sure to use the same name and email address.
This thread is now CLOSED. If you wish to comment, start a NEW discussion in
Excel Forum.