VBA code for outline border

  • Thread starter Thread starter Otto Moehrbach
  • Start date Start date
O

Otto Moehrbach

Excel XP & Win XP
When I record a macro and place an outline border, the recorder of course
lays down a bunch of lines encompassing every facet of the border.
Is there a simple command to produce an outline border? Thanks for your
time. Otto
 
Otto,

I'm assuming you want to create a single border around a range of cells, not
setting the borders for each individual cell in the range. Try

Range("C3:D20").BorderAround Weight:=xlMedium

You could modify this to

Selection.BorderAround Weight:=xlMedium
' or
ActiveCell.BorderAround Weight:=xlMedium

--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email address is on the web site)
 
Otto

To outline each cell in selection.............

Sub Border_Cells()
With Selection
.Borders.LineStyle = xlContinuous
.Borders.Weight = xlThick
.Borders.ColorIndex = xlAutomatic
End With
End Sub

To outline around cells in selection.........

Sub Border_Cells22()
With Selection.Borders
.LineStyle = xlContinuous
.Weight = xlThick
.ColorIndex = xlAutomatic
End With
With Selection
.Borders(xlInsideVertical).LineStyle = xlNone
.Borders(xlInsideHorizontal).LineStyle = xlNone
End With
End Sub


Gord
 
Chip
You're like a gold mine. Thanks for all your help, before as well as
now. Otto
 
Cool!

Thanks Chip.....never new the BorderAround existed. Found it in help under the
Range Object section.

Do you think I should read the Help section more often? <g>


Gord
 
Do you think I should read the Help section more often? <g>

Never hurts to read the Help. Actually, I find most of this sort of stuff by
poking around the Object Browser in VBA.

And speaking of Help, I've found the Help in Excel 2007 to be MUCH better
than the Help in previous versions. I've got it configured to search both
online and offline help, and everytime I've used it (mainly to find out
where in the hell they moved a command to), I've found what I'm looking for
on the first try. It seems that MS finally realized that Help was meant to
be used.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email address is on the web site)
 
Thanks Chip.

Not upgraded yet to 2007.

At my age the learning curve is getting steeper so may not bother.


Gord

Never hurts to read the Help. Actually, I find most of this sort of stuff by
poking around the Object Browser in VBA.

And speaking of Help, I've found the Help in Excel 2007 to be MUCH better
than the Help in previous versions. I've got it configured to search both
online and offline help, and everytime I've used it (mainly to find out
where in the hell they moved a command to), I've found what I'm looking for
on the first try. It seems that MS finally realized that Help was meant to
be used.

Gord Dibben MS Excel MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top