ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Insert new row and retain borders (https://www.excelbanter.com/excel-programming/379838-re-insert-new-row-retain-borders.html)

JLGWhiz

Insert new row and retain borders
 
This would be my approach:

If iDisp 10 Then
With oSheet.Range("A65536").Range("A" & iDisp + 4)
.EntireRow.Insert
'Set the line thickness to your liking
.BorderAround Weight:=xlThick, ColorIndex:=xlAutomatic
End With
End If

"hooie" wrote:

I have an Excel template that I'm filling from VB.NET and saving as a new
spreadsheet. If I add a new row, the formatting carries over but not the
cell borders. Is there an option or setting I'm missing?

<code
' Because this is in a neatly formatted template with only
10 rows (+4 rows of header),
' delete the last row in the spreadsheet and insert it back
where we need it.
If iDisp 10 Then
oSheet.Range("A65536").Rows.Delete()
oSheet.Range("A" & iDisp +
4).EntireRow.Insert(Excel.XlInsertShiftDirection.x lShiftDown,
Excel.XlInsertFormatOrigin.xlFormatFromLeftOrAbove )
End If
</code



All times are GMT +1. The time now is 11:07 PM.

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