PC Review


Reply
Thread Tools Rate Thread

Add Border to the right side (xlEdgeRight) of a large number of co

 
 
MattyO
Guest
Posts: n/a
 
      4th Aug 2008
So I have a very large report with a ton columns that I would to add a border
on the right edge. Do I need to repeat this code for each column (see
below), because the columns go way out to DE and that would see quite
cumbersome.
-------
Range("A9").Select
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With

Range("B9").Select
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
-----

Finally I tried this:
Range("A99").Borders(xlEdgeRight).Weight = xlThin

....but that only put the border on D9 and that doesn't work.

Thanks!

 
Reply With Quote
 
 
 
 
ker_01
Guest
Posts: n/a
 
      4th Aug 2008
When I record a macro while adding interior lines, I get the following:

Columns("AE").Select
Selection.Borders(xlEdgeLeft).LineStyle = xlNone
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With

HTH,
Keith


"MattyO" <(E-Mail Removed)> wrote in message
news:1631BC9D-5DBA-418A-8A6C-(E-Mail Removed)...
> So I have a very large report with a ton columns that I would to add a
> border
> on the right edge. Do I need to repeat this code for each column (see
> below), because the columns go way out to DE and that would see quite
> cumbersome.
> -------
> Range("A9").Select
> With Selection.Borders(xlEdgeRight)
> .LineStyle = xlContinuous
> .Weight = xlThin
> .ColorIndex = xlAutomatic
> End With
>
> Range("B9").Select
> With Selection.Borders(xlEdgeRight)
> .LineStyle = xlContinuous
> .Weight = xlThin
> .ColorIndex = xlAutomatic
> End With
> -----
>
> Finally I tried this:
> Range("A99").Borders(xlEdgeRight).Weight = xlThin
>
> ...but that only put the border on D9 and that doesn't work.
>
> Thanks!
>



 
Reply With Quote
 
MattyO
Guest
Posts: n/a
 
      4th Aug 2008
ker_01

In this case, I only want row 9 for all these columns to do this, not every
row in the worksheet.
When I change your first line out to Columns("A9E9").Select, it doesn't
work.


"ker_01" wrote:

> When I record a macro while adding interior lines, I get the following:
>
> Columns("AE").Select
> Selection.Borders(xlEdgeLeft).LineStyle = xlNone
> With Selection.Borders(xlEdgeRight)
> .LineStyle = xlContinuous
> .Weight = xlThin
> .ColorIndex = xlAutomatic
> End With
> With Selection.Borders(xlInsideVertical)
> .LineStyle = xlContinuous
> .Weight = xlThin
> .ColorIndex = xlAutomatic
> End With
>
> HTH,
> Keith
>
>
> "MattyO" <(E-Mail Removed)> wrote in message
> news:1631BC9D-5DBA-418A-8A6C-(E-Mail Removed)...
> > So I have a very large report with a ton columns that I would to add a
> > border
> > on the right edge. Do I need to repeat this code for each column (see
> > below), because the columns go way out to DE and that would see quite
> > cumbersome.
> > -------
> > Range("A9").Select
> > With Selection.Borders(xlEdgeRight)
> > .LineStyle = xlContinuous
> > .Weight = xlThin
> > .ColorIndex = xlAutomatic
> > End With
> >
> > Range("B9").Select
> > With Selection.Borders(xlEdgeRight)
> > .LineStyle = xlContinuous
> > .Weight = xlThin
> > .ColorIndex = xlAutomatic
> > End With
> > -----
> >
> > Finally I tried this:
> > Range("A99").Borders(xlEdgeRight).Weight = xlThin
> >
> > ...but that only put the border on D9 and that doesn't work.
> >
> > Thanks!
> >

>
>
>

 
Reply With Quote
 
ker_01
Guest
Posts: n/a
 
      4th Aug 2008
I was trying to imply that when you record a macro, it will give you a great
headstart on your code (since I interpreted your original post to be asking
how to add interior border lines to a range instead of selecting each cell
and adding one exterior border at a time).

If you are trying to use macro code without any edits, I'm not surprised
that it doesn't work 'out of the box' - Excel is funny that way. Again if I
were to guess, you probably need to tell it which sheet you want this code
to execute on, such as Sheet1.Columns("A9E9").Select. However, without
knowing what error you got (or what symptoms lead you to say "it doesn't
work" it is hard to give definitive advice.

HTH,
Keith

"MattyO" <(E-Mail Removed)> wrote in message
news:C08345A4-083C-4DA7-A975-(E-Mail Removed)...
> ker_01
>
> In this case, I only want row 9 for all these columns to do this, not
> every
> row in the worksheet.
> When I change your first line out to Columns("A9E9").Select, it doesn't
> work.
>
>
> "ker_01" wrote:
>
>> When I record a macro while adding interior lines, I get the following:
>>
>> Columns("AE").Select
>> Selection.Borders(xlEdgeLeft).LineStyle = xlNone
>> With Selection.Borders(xlEdgeRight)
>> .LineStyle = xlContinuous
>> .Weight = xlThin
>> .ColorIndex = xlAutomatic
>> End With
>> With Selection.Borders(xlInsideVertical)
>> .LineStyle = xlContinuous
>> .Weight = xlThin
>> .ColorIndex = xlAutomatic
>> End With
>>
>> HTH,
>> Keith
>>
>>
>> "MattyO" <(E-Mail Removed)> wrote in message
>> news:1631BC9D-5DBA-418A-8A6C-(E-Mail Removed)...
>> > So I have a very large report with a ton columns that I would to add a
>> > border
>> > on the right edge. Do I need to repeat this code for each column (see
>> > below), because the columns go way out to DE and that would see quite
>> > cumbersome.
>> > -------
>> > Range("A9").Select
>> > With Selection.Borders(xlEdgeRight)
>> > .LineStyle = xlContinuous
>> > .Weight = xlThin
>> > .ColorIndex = xlAutomatic
>> > End With
>> >
>> > Range("B9").Select
>> > With Selection.Borders(xlEdgeRight)
>> > .LineStyle = xlContinuous
>> > .Weight = xlThin
>> > .ColorIndex = xlAutomatic
>> > End With
>> > -----
>> >
>> > Finally I tried this:
>> > Range("A99").Borders(xlEdgeRight).Weight = xlThin
>> >
>> > ...but that only put the border on D9 and that doesn't work.
>> >
>> > Thanks!
>> >

>>
>>
>>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding only a left side border Bob Microsoft Word Document Management 2 4th Nov 2008 01:28 AM
Right Hand Side Page Border SandyC Microsoft Word Document Management 1 29th Sep 2008 09:58 AM
Right side border on web site =?Utf-8?B?RGFycmVsbEc=?= Microsoft Frontpage 1 19th Feb 2007 09:23 PM
different colour each side of diagonal border =?Utf-8?B?ZnJpc2J5?= Microsoft Excel Misc 2 19th Jun 2006 03:55 PM
Getting rid of one side a border? Shaun Allan Microsoft Excel Programming 2 24th Jul 2004 03:57 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:29 PM.