View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Hari[_3_] Hari[_3_] is offline
external usenet poster
 
Posts: 157
Default Border problem with one row but no snag in many rows

Hi,

I have text from B3 to O3.

I recorded a macro to apply "All borders" in this range which I have pasted
below.

If I use the same macro for applying the same border style to some other one
row range like b4 to O4 then macro fails at each of the 3 lines following
"With Selection.Borders(xlInsideHorizontal)"

If I use the same macro for applying the all border to more than one row
range then the macro doesnt fail.

Why?. Surprising thing is the macro itself was recorded based on one row
selection then why is it that it fails inspite of having the same starting
conditions for the macro

Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With


Regards,
Hari
India