ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   automatically insert rows (https://www.excelbanter.com/excel-programming/312504-automatically-insert-rows.html)

Samuel[_4_]

automatically insert rows
 
Hello,

I've a sheet with records from cell a to k, where i want to insert a row
between each record (there are 2000 records in the sheet) and the value
union in the first cell of the newly inserted row.

How can i do this?



Tom Ogilvy

automatically insert rows
 
Sub AddRows()
Dim lastRow as Long, i as Long
lastrow = cells(rows.count,1).end(xlup).row
for i = lastrow to 1 step -1
cells(i,1).Entirerow.Insert
cells(i,1).Value = "Union"
Next
End Sub

Test this on a copy of your data.
--
Regards,
Tom Ogilvy

"Samuel" wrote in message
...
Hello,

I've a sheet with records from cell a to k, where i want to insert a row
between each record (there are 2000 records in the sheet) and the value
union in the first cell of the newly inserted row.

How can i do this?






All times are GMT +1. The time now is 05:15 PM.

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