ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   problem formatting lines around cells (https://www.excelbanter.com/excel-programming/428204-problem-formatting-lines-around-cells.html)

Russ

problem formatting lines around cells
 
I have reduced the problem to the following test case.
I have a workbook with one sheet. In cell(4, 1) I have manually formatted
the cell to have a lower edge line and right edge line (this is a header row
in the real workbook). When I manually delete row 5 the formatting in
cell(4, 1) remains unchanged. However, if I execute the following subroutine
which puts a right edge in cell(5, 1) and then manually delete row 5 the
lower edge line in cell(4, 1) is removed. In the real workbook I am adding
multiple rows below row 4 with code. What am I missing? I would not like to
have to code row 5 different from the rows below in order to get the lines
properly placed
Option Explicit
Public Sub formatter()
Dim sh As Object
Dim r as long
Set sh = ActiveWorkbook.Sheets("Sheet1")
r = 5
With sh
With Cells(r, 1)
With .Borders(xlEdgeRight)
.LineStyle = xlContinuous
.ColorIndex = xlAutomatic
.TintAndShade = 0
.Weight = xlThin
End With
End With
End With
End Sub

--
russ


All times are GMT +1. The time now is 10:33 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com