ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   VBA code for outline border (https://www.excelbanter.com/excel-programming/379965-vba-code-outline-border.html)

Otto Moehrbach

VBA code for outline border
 
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



Chip Pearson

VBA code for outline border
 
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 Moehrbach" wrote in message
...
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




Gord Dibben

VBA code for outline border
 
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

On Sat, 23 Dec 2006 14:05:51 -0500, "Otto Moehrbach"
wrote:

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 Moehrbach

VBA code for outline border
 
Chip
You're like a gold mine. Thanks for all your help, before as well as
now. Otto
"Chip Pearson" wrote in message
...
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 Moehrbach" wrote in message
...
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






Gord Dibben

VBA code for outline border
 
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

On Sat, 23 Dec 2006 13:18:12 -0600, "Chip Pearson" wrote:

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



Chip Pearson

VBA code for outline border
 
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)



"Gord Dibben" <gorddibbATshawDOTca wrote in message
...
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

On Sat, 23 Dec 2006 13:18:12 -0600, "Chip Pearson"
wrote:

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





Gord Dibben

VBA code for outline border
 
Thanks Chip.

Not upgraded yet to 2007.

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


Gord

On Sat, 23 Dec 2006 15:13:05 -0600, "Chip Pearson" wrote:

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.


Gord Dibben MS Excel MVP


All times are GMT +1. The time now is 04:08 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com