adding a row on a sheet that has multiple sections

lillypop

New Member
Joined
Jul 20, 2018
Messages
14
Hello,

I need to add a row each month at the bottom of other rows accumulated from previous months, with the same format and some formulas from the row above. (eg. area B2:BB100).

I firstly tried to detect the last active cell in column B, and copy and paste a row underneath it, but because there is another table underneath, it keeps on adding a row below that last table on the sheet. Now I try to define the first table (e.g. from B2:BB100 = "Table1"), and add a row below it, shift down, but the defined area is always fixed, which is not what I want, because the table area should increase each month. Any idea?



Sub addrow()

Dim NewRow as Range

With Range("Table1").EntireRow(Range("Table1").Rows.Count).Offset(0,0)
.EntireRow.Copy

With.Offset(1,0).EntireRow
.PasteSpecial XlPasteFormats
.PasteSpecial XlPasteFormulas

on Error Resume Next
.SpecialCells(xlCellTypeCOnstants).ClearContents
On Error Goto 0

End With
End With

End sub
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
If you want to add a row to the bottom of Table1, you may want to try this line of code. It will automatically pick up the formulas and formats.

Code:
[COLOR=#2D2C2A][FONT=Verdana]ActiveSheet.ListObjects("Table1").ListRows.Add AlwaysInsert:= True[/FONT][/COLOR]
 
Upvote 0

Forum statistics

Threads
1,215,526
Messages
6,125,328
Members
449,218
Latest member
Excel Master

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top