Search code examples
excelvbainsertrow

Insert a row below the last cell and not above it


Can anyone please help me with this?

I am trying to write a macro that will insert a new row with text, after the last row that has text in it on page 1 - please see the image below.

enter image description here

I want the macro to insert a new row on PAGE 1, after row 16, thus expanding the border of page 1 or in other words below it.

But it only inserts a row above for some reason. I need it to insert below.

Here is the code -

Sub Macro5()


lastrow = Cells(Rows.Count, 1).End(xlUp).Row

Rows(lastrow).Select

Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove


End Sub

Should be a simple task, but for some reason, I can't find the answer.

Thank you in advance.


Solution

  • Modify just one line

    lastrow = Cells(Rows.Count, 1).End(xlUp).Row + 1