In my vb.net application, I create a new worksheet in an existing Excel workbook by transferring data from an MS Access query.
With the following code (thanks again Harry Lee!), a range is selected in the new worksheet then copied to a different range in an old worksheet in the same workbook:
Dim NewWS As Worksheet, OldWS As Worksheet, NewRng As Range, OldLastRW As Long
NewWS = objExcel.Sheets("NewData")
OldWS = objExcel.Sheets("OldData")
OldLastRW = OldWS.Cells(OldWS.Rows.Count, 1).End(XlDirection.xlUp).Row
NewRng = NewWS.Range(NewWS.Cells(2, 1), NewWS.Cells(NewWS.Cells _(NewWS.Rows.Count, 1).End(XlDirection.xlUp).Row, 12))
NewRng.Copy(OldWS.Cells(OldLastRW + 2, 1))
All works well, but when the new worksheet was initially created from the Access query, the cells with data in them have borders which I do not want copied to the new worksheet.
What can I add/modify in the above code to prevent any formatting being copied with the data?