Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Greetings and TIA for your time
I would like to apply a hairline border to every cell in a range. I can mimic the recorder code with a long list of instructions (xlLeft, xlRight, etc.) but is their a short and tidy method? -- David |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi David
I would like to apply a hairline border to every cell in a range. I can mimic the recorder code with a long list of instructions (xlLeft, xlRight, etc.) but is their a short and tidy method? Sub test() Dim bdrs As Borders Set bdrs = Range("b3:e6").Borders bdrs.LineStyle = xlContinuous bdrs.Weight = xlHairline bdrs.ColorIndex = 5 End Sub Regards, Peter T |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks Peter,
Works good, Since posting I also found: Selection.BorderAround xlContinuous, xlHairline works good too -- David "Peter T" wrote: Hi David Sub test() Dim bdrs As Borders Set bdrs = Range("b3:e6").Borders bdrs.LineStyle = xlContinuous bdrs.Weight = xlHairline bdrs.ColorIndex = 5 End Sub Regards, Peter T |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi David,
Since posting I also found: Selection.BorderAround xlContinuous, xlHairline works good too That applies borders to the outside edges of the range but not the insides. You originally asked I would like to apply a hairline border to every cell in a range. Only if your range comprises of one or more single cell areas would both methods do same. So if you only want to do the outside, use "BorderAround", otherwise the apply to the entire Borders collection in one go (assuming you want same properties for all). Regards, Peter T "David" wrote in message ... Thanks Peter, Works good, Since posting I also found: Selection.BorderAround xlContinuous, xlHairline works good too -- David "Peter T" wrote: Hi David Sub test() Dim bdrs As Borders Set bdrs = Range("b3:e6").Borders bdrs.LineStyle = xlContinuous bdrs.Weight = xlHairline bdrs.ColorIndex = 5 End Sub Regards, Peter T |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks Peter,
Of course, I would be looping through the range one cell at a time with the 'BordersAround' code, but your suggestion would be more efficient I imagine. -- David "Peter T" wrote: Hi David, Since posting I also found: Selection.BorderAround xlContinuous, xlHairline works good too That applies borders to the outside edges of the range but not the insides. You originally asked I would like to apply a hairline border to every cell in a range. Only if your range comprises of one or more single cell areas would both methods do same. So if you only want to do the outside, use "BorderAround", otherwise the apply to the entire Borders collection in one go (assuming you want same properties for all). Regards, Peter T "David" wrote in message ... Thanks Peter, Works good, Since posting I also found: Selection.BorderAround xlContinuous, xlHairline works good too -- David "Peter T" wrote: Hi David Sub test() Dim bdrs As Borders Set bdrs = Range("b3:e6").Borders bdrs.LineStyle = xlContinuous bdrs.Weight = xlHairline bdrs.ColorIndex = 5 End Sub Regards, Peter T |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Merged Cell Conditional Formatting Borders | Excel Discussion (Misc queries) | |||
Sometimes a cell will not allow formatting, like borders | Excel Discussion (Misc queries) | |||
Can you apply split colour formatting to the same cell? | Excel Discussion (Misc queries) | |||
formatting won't apply to my cell with a formula | Excel Worksheet Functions | |||
Cell Formatting or Borders | Excel Discussion (Misc queries) |