Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Border Formats

Hi All
To format the outer borders of a selection, I use this code:

A = 3
Range("C34:J42").Select
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = A
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = A
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = A
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = A
End With

It's very cumbersome, but I have had no success trying to compact it.
Is it possible to combine the 4 borders into a single statement, and then
apply the 3 format lines just once?

Regards - Dave.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Border Formats

Sub abcd()
Range("C34:J42").BorderAround _
Weight:=xlMedium, ColorIndex:=3

End Sub

--
Regards,
Tom Ogilvy


"Dave" wrote in message
...
Hi All
To format the outer borders of a selection, I use this code:

A = 3
Range("C34:J42").Select
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = A
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = A
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = A
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = A
End With

It's very cumbersome, but I have had no success trying to compact it.
Is it possible to combine the 4 borders into a single statement, and then
apply the 3 format lines just once?

Regards - Dave.




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 414
Default Border Formats

Try:

Const A As Long = 3
Range("C34:J42").BorderAround xlContinuous, xlMedium, A

Hope this helps
Rowan

Dave wrote:
Hi All
To format the outer borders of a selection, I use this code:

A = 3
Range("C34:J42").Select
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = A
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = A
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = A
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = A
End With

It's very cumbersome, but I have had no success trying to compact it.
Is it possible to combine the 4 borders into a single statement, and then
apply the 3 format lines just once?

Regards - Dave.


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Border Formats

Thanks very much. Exactly what I was after. I used the macro recorder to
do it originally, and that was the code it produced.

Dave.

"Tom Ogilvy" wrote in message
...
Sub abcd()
Range("C34:J42").BorderAround _
Weight:=xlMedium, ColorIndex:=3

End Sub

--
Regards,
Tom Ogilvy


"Dave" wrote in message
...
Hi All
To format the outer borders of a selection, I use this code:

A = 3
Range("C34:J42").Select
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = A
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = A
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = A
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = A
End With

It's very cumbersome, but I have had no success trying to compact it.
Is it possible to combine the 4 borders into a single statement, and

then
apply the 3 format lines just once?

Regards - Dave.






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Border Formats


Hi Tom,
If this works:

Sub abcd()
Range("C34:J42").BorderAround _
Weight:=xlMedium, ColorIndex:=3
End Sub

Then why won't this work?

Sub abcd()
With Selection.BorderAround _
Weight:=xlMedium, ColorIndex:=3
End With
End Sub

Tom Ogilvy Wrote:
Sub abcd()
Range("C34:J42").BorderAround _
Weight:=xlMedium, ColorIndex:=3

End Sub

--
Regards,
Tom Ogilvy


"Dave" wrote in message
...
Hi All
To format the outer borders of a selection, I use this code:

A = 3
Range("C34:J42").Select
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = A
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = A
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = A
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = A
End With

It's very cumbersome, but I have had no success trying to compac

it.
Is it possible to combine the 4 borders into a single statement, an

then
apply the 3 format lines just once?

Regards - Dave.



--
Desert Piranh

-----------------------------------------------------------------------
Desert Piranha's Profile: http://www.excelforum.com/member.php...fo&userid=2893
View this thread: http://www.excelforum.com/showthread.php?threadid=49477



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 414
Default Border Formats

Try:

With Selection
.BorderAround Weight:=xlMedium, ColorIndex:=3
End With

Regards
Rowan

Desert Piranha wrote:
Hi Tom,
If this works:

Sub abcd()
Range("C34:J42").BorderAround _
Weight:=xlMedium, ColorIndex:=3
End Sub

Then why won't this work?

Sub abcd()
With Selection.BorderAround _
Weight:=xlMedium, ColorIndex:=3
End With
End Sub

Tom Ogilvy Wrote:

Sub abcd()
Range("C34:J42").BorderAround _
Weight:=xlMedium, ColorIndex:=3

End Sub

--
Regards,
Tom Ogilvy


"Dave" wrote in message
...

Hi All
To format the outer borders of a selection, I use this code:

A = 3
Range("C34:J42").Select
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = A
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = A
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = A
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = A
End With

It's very cumbersome, but I have had no success trying to compact


it.

Is it possible to combine the 4 borders into a single statement, and


then

apply the 3 format lines just once?

Regards - Dave.





  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Border Formats


Hi Rowan,

Thx, i knew it was something stupid that i was doing wrong.

Thx Again
Dave
Rowan Drummond Wrote:
Try:

With Selection
.BorderAround Weight:=xlMedium, ColorIndex:=3
End With

Regards
Rowan

Desert Piranha wrote:
Hi Tom,
If this works:

Sub abcd()
Range("C34:J42").BorderAround _
Weight:=xlMedium, ColorIndex:=3
End Sub

Then why won't this work?

Sub abcd()
With Selection.BorderAround _
Weight:=xlMedium, ColorIndex:=3
End With
End Sub

Tom Ogilvy Wrote:

Sub abcd()
Range("C34:J42").BorderAround _
Weight:=xlMedium, ColorIndex:=3

End Sub

--
Regards,
Tom Ogilvy


"Dave" wrote in message
...

Hi All
To format the outer borders of a selection, I use this code:

A = 3
Range("C34:J42").Select
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = A
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = A
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = A
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = A
End With

It's very cumbersome, but I have had no success trying to compact

it.

Is it possible to combine the 4 borders into a single statement,

and

then

apply the 3 format lines just once?

Regards - Dave.







--
Desert Piranha


------------------------------------------------------------------------
Desert Piranha's Profile: http://www.excelforum.com/member.php...o&userid=28934
View this thread: http://www.excelforum.com/showthread...hreadid=494774

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 325
Default Border Formats

Rowan,

What's the quickest way to remove ALL border formatting from a range i.e.
top right, left, buttom, inside horizontal and vertical and diagonals?

Cheers

Pete



"Rowan Drummond" wrote:

Try:

With Selection
.BorderAround Weight:=xlMedium, ColorIndex:=3
End With

Regards
Rowan

Desert Piranha wrote:
Hi Tom,
If this works:

Sub abcd()
Range("C34:J42").BorderAround _
Weight:=xlMedium, ColorIndex:=3
End Sub

Then why won't this work?

Sub abcd()
With Selection.BorderAround _
Weight:=xlMedium, ColorIndex:=3
End With
End Sub

Tom Ogilvy Wrote:

Sub abcd()
Range("C34:J42").BorderAround _
Weight:=xlMedium, ColorIndex:=3

End Sub

--
Regards,
Tom Ogilvy


"Dave" wrote in message
...

Hi All
To format the outer borders of a selection, I use this code:

A = 3
Range("C34:J42").Select
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = A
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = A
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = A
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = A
End With

It's very cumbersome, but I have had no success trying to compact

it.

Is it possible to combine the 4 borders into a single statement, and

then

apply the 3 format lines just once?

Regards - Dave.






  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 709
Default Border Formats

Our just,
Selection.BorderAround _
Weight:=xlMedium, ColorIndex:=3


--
Paul B
Always backup your data before trying something new
Please post any response to the newsgroups so others can benefit from it
Feedback on answers is always appreciated!
Using Excel 2002 & 2003

"Desert Piranha"
<Desert.Piranha.20bmvy_1135053000.9335@excelforu m-nospam.com wrote in
message news:Desert.Piranha.20bmvy_1135053000.9335@excelfo rum-nospam.com...

Hi Rowan,

Thx, i knew it was something stupid that i was doing wrong.

Thx Again
Dave
Rowan Drummond Wrote:
Try:

With Selection
.BorderAround Weight:=xlMedium, ColorIndex:=3
End With

Regards
Rowan

Desert Piranha wrote:
Hi Tom,
If this works:

Sub abcd()
Range("C34:J42").BorderAround _
Weight:=xlMedium, ColorIndex:=3
End Sub

Then why won't this work?

Sub abcd()
With Selection.BorderAround _
Weight:=xlMedium, ColorIndex:=3
End With
End Sub

Tom Ogilvy Wrote:

Sub abcd()
Range("C34:J42").BorderAround _
Weight:=xlMedium, ColorIndex:=3

End Sub

--
Regards,
Tom Ogilvy


"Dave" wrote in message
...

Hi All
To format the outer borders of a selection, I use this code:

A = 3
Range("C34:J42").Select
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = A
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = A
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = A
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = A
End With

It's very cumbersome, but I have had no success trying to compact

it.

Is it possible to combine the 4 borders into a single statement,

and

then

apply the 3 format lines just once?

Regards - Dave.







--
Desert Piranha


------------------------------------------------------------------------
Desert Piranha's Profile:

http://www.excelforum.com/member.php...o&userid=28934
View this thread: http://www.excelforum.com/showthread...hreadid=494774



  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Border Formats

'set rng = selection
rng.Borders.LineStyle = xlNone

Regards,
Peter T

"Peter Rooney" wrote in message
...
Rowan,

What's the quickest way to remove ALL border formatting from a range i.e.
top right, left, buttom, inside horizontal and vertical and diagonals?

Cheers

Pete

<snip




  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 325
Default Border Formats

Peter,

Spot on - thanks a lot!

Have a good Christmas, too.

Pete



"Peter T" wrote:

'set rng = selection
rng.Borders.LineStyle = xlNone

Regards,
Peter T

"Peter Rooney" wrote in message
...
Rowan,

What's the quickest way to remove ALL border formatting from a range i.e.
top right, left, buttom, inside horizontal and vertical and diagonals?

Cheers

Pete

<snip



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
Border Limitations for Conditional Formats Blue Max New Users to Excel 3 April 5th 10 01:28 PM
border on last cell of page effects border on beginning cell of ne GaryE Excel Discussion (Misc queries) 0 March 23rd 09 05:47 AM
Can two formats be applied to a cell with a diagonal border Deb-Ellen Excel Discussion (Misc queries) 1 May 7th 08 10:28 AM
Changing the border of one cell s/n change the border of adjacent gjanssenmn Excel Discussion (Misc queries) 2 October 5th 05 08:35 PM
Can border formats be locked? Eric[_14_] Excel Programming 1 January 21st 04 03:20 PM


All times are GMT +1. The time now is 12:39 AM.

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

About Us

"It's about Microsoft Excel"