Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() 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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() 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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
'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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Border Limitations for Conditional Formats | New Users to Excel | |||
border on last cell of page effects border on beginning cell of ne | Excel Discussion (Misc queries) | |||
Can two formats be applied to a cell with a diagonal border | Excel Discussion (Misc queries) | |||
Changing the border of one cell s/n change the border of adjacent | Excel Discussion (Misc queries) | |||
Can border formats be locked? | Excel Programming |