View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
JLGWhiz JLGWhiz is offline
external usenet poster
 
Posts: 3,986
Default 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