View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
David David is offline
external usenet poster
 
Posts: 1,560
Default cell formatting - apply borders

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