ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Insert cells at end of selection (https://www.excelbanter.com/excel-programming/436289-re-insert-cells-end-selection.html)

Kirsty

Insert cells at end of selection
 
Thanks Rick,

The only problem is that it is inserting the row, two rows above the last
row in teh range with data, not above the last row.

The last row has a merged cell A:H. Will this affect it?

Kirsty

"Rick Rothstein" wrote:

This should do what you want, just assign the number of rows of cells in
Columns A through R to insert to the NumberOfBlankRows variable (I used 4
for my example code)...

Sub InsertBlankCellsColumnsAtoR()
Dim LastRow As Long, NumberOfBlankRows
NumberOfBlankRows = 4
LastRow = Range("A3:R1000").Find(What:="*", SearchOrder:=xlColumns, _
SearchDirection:=xlPrevious, LookIn:=xlValues).Row
Intersect(Range("A:R"), Rows(LastRow)).Resize(NumberOfBlankRows).Insert
End Sub

--
Rick (MVP - Excel)


"Kirsty" wrote in message
...
Hi,

I have a macro that I want to change to go look in a range of cells
A3:R1000
and find the last row with data.

I then want to step back and insert cells above this row.

Eg, i have data in row 140, so I want to insert cells to get a blank lot
of
cells in row 140 from columns A to R.

Is this possible?

Kirsty


.



All times are GMT +1. The time now is 06:48 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com