NorthbyNorthwest
Board Regular
- Joined
- Oct 27, 2013
- Messages
- 154
- Office Version
- 365
Hi, everyone. I am working with a table (listobject). I notice the exact formatting sometimes fails to carry over when I add a row to the bottom of the table. Don't understand why this happens. I thought consistent formatting was a feature of tables. Anyway, I would like to add a bit a code following each row addition. I simply want the code to copy the row above the new addition and paste formatting to new row. I tried with code below. But it blows up. Can someone assist?
Sub LastRow()
Dim loLastRow As Long
With ActiveSheet.ListObjects("Details")
loLastRow = .DataBodyRange.Rows.Count + .HeaderRowRange.Row
'MsgBox loLastRow
.ListRows(loLastRow.Offset(-1, 0)).Range.Copy
.ListRows(loLastRow).Range.PasteSpecial Paste: xlFormats
End With
End Sub
Sub LastRow()
Dim loLastRow As Long
With ActiveSheet.ListObjects("Details")
loLastRow = .DataBodyRange.Rows.Count + .HeaderRowRange.Row
'MsgBox loLastRow
.ListRows(loLastRow.Offset(-1, 0)).Range.Copy
.ListRows(loLastRow).Range.PasteSpecial Paste: xlFormats
End With
End Sub