Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,090
Default Borders within a With/End With

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


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,582
Default Borders within a With/End With

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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,090
Default Borders within a With/End With

Thanks Jon. I'll give that a try. Otto
"Jon Peltier" wrote in message
...
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" wrote in message
...
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





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Borders within a With/End With

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


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 318
Default Borders within a With/End With

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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
borders kim Excel Discussion (Misc queries) 1 October 12th 07 10:24 PM
Borders DAH Mist Excel Discussion (Misc queries) 0 October 1st 07 10:24 PM
Borders anita Excel Worksheet Functions 6 September 15th 06 01:15 PM
borders jobra Excel Programming 4 August 30th 05 10:55 AM
borders Brush Prairie Excel Discussion (Misc queries) 0 August 23rd 05 02:57 AM


All times are GMT +1. The time now is 07:45 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"