PC Review


Reply
Thread Tools Rate Thread

Borders within a With/End With

 
 
Otto Moehrbach
Guest
Posts: n/a
 
      7th Jan 2007
Excel XP & Win XP
I have the following code to place a black thin border around every cell in
the range, and a thick colored border around (outline) the whole range. I
get an error "Object Required" on the first line and would probably get the
same error on the second line if the code got past the first line. What is
the proper syntax/code to do what I want? Thanks for your time. Otto
With ws
.["F1:H6"].Borders LineStyle:=xlContinuous, Weight:=xlThin,
ColorIndex:=xlAutomatic
.["F1:H6"].BorderAround LineStyle:=xlContinuous,
Weight:=xlThick, ColorIndex:=9
.["F1:H6"].Interior.ColorIndex = 36
End With


 
Reply With Quote
 
 
 
 
Jon Peltier
Guest
Posts: n/a
 
      7th Jan 2007
First, I wouldn't use ["F1:H6"] (or any of the [] shorthand), but
Range("F1:H6"). The shorthand is sometimes convenient, sometimes confusing
and misleading, and sometimes makes it hard to track down a problem.

Second, I think what you need is
With ws
With .Range("F1:H6").Borders
.LineStyle=xlContinuous
.Weight=xlThin
.ColorIndex:=xlAutomatic
End With
' etc.
End With

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
http://PeltierTech.com
_______


"Otto Moehrbach" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Excel XP & Win XP
> I have the following code to place a black thin border around every cell
> in the range, and a thick colored border around (outline) the whole range.
> I get an error "Object Required" on the first line and would probably get
> the same error on the second line if the code got past the first line.
> What is the proper syntax/code to do what I want? Thanks for your time.
> Otto
> With ws
> .["F1:H6"].Borders LineStyle:=xlContinuous, Weight:=xlThin,
> ColorIndex:=xlAutomatic
> .["F1:H6"].BorderAround LineStyle:=xlContinuous,
> Weight:=xlThick, ColorIndex:=9
> .["F1:H6"].Interior.ColorIndex = 36
> End With
>



 
Reply With Quote
 
Otto Moehrbach
Guest
Posts: n/a
 
      7th Jan 2007
Thanks Jon. I'll give that a try. Otto
"Jon Peltier" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> First, I wouldn't use ["F1:H6"] (or any of the [] shorthand), but
> Range("F1:H6"). The shorthand is sometimes convenient, sometimes confusing
> and misleading, and sometimes makes it hard to track down a problem.
>
> Second, I think what you need is
> With ws
> With .Range("F1:H6").Borders
> .LineStyle=xlContinuous
> .Weight=xlThin
> .ColorIndex:=xlAutomatic
> End With
> ' etc.
> End With
>
> - Jon
> -------
> Jon Peltier, Microsoft Excel MVP
> Tutorials and Custom Solutions
> http://PeltierTech.com
> _______
>
>
> "Otto Moehrbach" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> Excel XP & Win XP
>> I have the following code to place a black thin border around every cell
>> in the range, and a thick colored border around (outline) the whole
>> range. I get an error "Object Required" on the first line and would
>> probably get the same error on the second line if the code got past the
>> first line. What is the proper syntax/code to do what I want? Thanks for
>> your time. Otto
>> With ws
>> .["F1:H6"].Borders LineStyle:=xlContinuous, Weight:=xlThin,
>> ColorIndex:=xlAutomatic
>> .["F1:H6"].BorderAround LineStyle:=xlContinuous,
>> Weight:=xlThick, ColorIndex:=9
>> .["F1:H6"].Interior.ColorIndex = 36
>> End With
>>

>
>



 
Reply With Quote
 
Ron de Bruin
Guest
Posts: n/a
 
      7th Jan 2007
Hi Otto

Record a macro when you do it manual and look a t the code


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Otto Moehrbach" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
> Excel XP & Win XP
> I have the following code to place a black thin border around every cell in
> the range, and a thick colored border around (outline) the whole range. I
> get an error "Object Required" on the first line and would probably get the
> same error on the second line if the code got past the first line. What is
> the proper syntax/code to do what I want? Thanks for your time. Otto
> With ws
> .["F1:H6"].Borders LineStyle:=xlContinuous, Weight:=xlThin,
> ColorIndex:=xlAutomatic
> .["F1:H6"].BorderAround LineStyle:=xlContinuous,
> Weight:=xlThick, ColorIndex:=9
> .["F1:H6"].Interior.ColorIndex = 36
> End With
>
>

 
Reply With Quote
 
=?Utf-8?B?QWxvaw==?=
Guest
Posts: n/a
 
      7th Jan 2007
Hi Otto,
What you tried implies that Borders is a method. In fact it is a collection.
Try
With Range("A1:B6").Borders
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With


"Otto Moehrbach" wrote:

> Excel XP & Win XP
> I have the following code to place a black thin border around every cell in
> the range, and a thick colored border around (outline) the whole range. I
> get an error "Object Required" on the first line and would probably get the
> same error on the second line if the code got past the first line. What is
> the proper syntax/code to do what I want? Thanks for your time. Otto
> With ws
> .["F1:H6"].Borders LineStyle:=xlContinuous, Weight:=xlThin,
> ColorIndex:=xlAutomatic
> .["F1:H6"].BorderAround LineStyle:=xlContinuous,
> Weight:=xlThick, ColorIndex:=9
> .["F1:H6"].Interior.ColorIndex = 36
> End With
>
>
>

 
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
lines & colored table borders, shared borders, thumbnails Jan Microsoft Frontpage 2 30th Mar 2008 07:13 PM
Borders =?Utf-8?B?QmlsbCBnb2xk?= Microsoft Frontpage 3 6th May 2007 05:22 PM
tables - green borders? blue borders? yikes DianaH Microsoft Frontpage 4 13th Oct 2005 09:22 AM
Why does page borders not appear in my borders and shading format. =?Utf-8?B?TW93Z2xp?= Microsoft Word Document Management 4 11th Jan 2005 08:40 PM
Page borders and table borders =?Utf-8?B?SGVsZW4=?= Microsoft Word Document Management 3 24th Sep 2004 01:29 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:15 PM.