Macro to find last cell and insert row below

dmcclel

New Member
Joined
Jul 28, 2011
Messages
8
I need help creating a macro that will find the last cell in a column that has data in it, then insert a blank row after that cell.
Thanks
 
Last edited:

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
Hi,

Try this (where the number in bold is the column with data in it):

This will insert a blank row before the cell:
Code:
Sub Example()
    Cells(Rows.Count, [B]1[/B]).End(xlUp).EntireRow.Insert
End Sub

This will insert a blank row after the cell:
Code:
Sub Example()
    Cells(Rows.Count, [B]1[/B]).End(xlUp).Offset(1, 0).EntireRow.Insert
End Sub
 
Last edited:
Upvote 0
Does this do what you want (adjust the column letter to suit your setup)...

Code:
Cells(Rows.Count, "A").End(xlUp).EntireRow.Insert
 
Upvote 0
I need help creating a macro that will find the last cell in a column that has data in it, then insert a blank row.
Thanks

the easiest way I can think of is to use Range("A104876").End(xlup).Insert Shift:=xlDown

You'll need to tweak the range depending on if you want to dynamically change the column you are looking at.


Edit: Cells (Rows.Count,"A") is cleaner
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,603
Messages
6,179,849
Members
452,948
Latest member
UsmanAli786

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