PDA

View Full Version : Solved: Put borders around selected range



alstubna
05-28-2011, 12:51 PM
Hello members!

Not much of a programmer.

All I want to do is put a thin line border around each cell in the selected range.

I used the macro recorder and it generated about 50 lines of code. I kind of figured that it could be done with a few lines of code using a For Next loop but I'm failing miserably!

Basically, I want to do this:

For each cell in selection
put a thin line border around the cell
next cell

Can anyone point me in the right direction?

mikerickson
05-28-2011, 12:59 PM
Looping is not needed
Sub trial()
With Selection.Borders
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
End Sub

alstubna
05-28-2011, 01:08 PM
Nice and compact.

Works very well.

Thank you, mikerickson