ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   New Users to Excel (https://www.excelbanter.com/new-users-excel/)
-   -   Insert Rows in b/w (https://www.excelbanter.com/new-users-excel/219042-insert-rows-b-w.html)

Ranjit kurian

Insert Rows in b/w
 
Hi

I have a column with few number, i need a macro code which will insert 4
rows after every number

example:
Amount
1
2
3
4
5
Answer:
1



2



3



4

Bernard Liengme

Insert Rows in b/w
 
Sub Macro1()
For irow = Cells(Rows.Count, "A").End(xlUp).Row To 2 Step -1
For k = 1 To 4
Cells(irow, "A").EntireRow.Insert
Next k
Next irow
End Sub

best wishes
--
Bernard V Liengme
Microsoft Excel MVP
http://people.stfx.ca/bliengme
remove caps from email

"Ranjit kurian" wrote in message
...
Hi

I have a column with few number, i need a macro code which will insert 4
rows after every number

example:
Amount
1
2
3
4
5
Answer:
1



2



3



4




Ranjit kurian

Insert Rows in b/w
 
This code is working fine,Thanks for it.
Could you please explain me the 'irow' concept


"Bernard Liengme" wrote:

Sub Macro1()
For irow = Cells(Rows.Count, "A").End(xlUp).Row To 2 Step -1
For k = 1 To 4
Cells(irow, "A").EntireRow.Insert
Next k
Next irow
End Sub

best wishes
--
Bernard V Liengme
Microsoft Excel MVP
http://people.stfx.ca/bliengme
remove caps from email

"Ranjit kurian" wrote in message
...
Hi

I have a column with few number, i need a macro code which will insert 4
rows after every number

example:
Amount
1
2
3
4
5
Answer:
1



2



3



4





Don Guillett

Insert Rows in b/w
 
try this
Sub insertrows()
For i = Cells(Rows.Count, 1).End(xlUp).Row To 2 Step -1
Rows(i).Resize(4).Insert
Next i
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Ranjit kurian" wrote in message
...
Hi

I have a column with few number, i need a macro code which will insert 4
rows after every number

example:
Amount
1
2
3
4
5
Answer:
1



2



3



4



Bernard Liengme

Insert Rows in b/w
 
It is just a variable name, I could have used "j"
best wishes
--
Bernard V Liengme
Microsoft Excel MVP
http://people.stfx.ca/bliengme
remove caps from email

"Ranjit kurian" wrote in message
...
This code is working fine,Thanks for it.
Could you please explain me the 'irow' concept


"Bernard Liengme" wrote:

Sub Macro1()
For irow = Cells(Rows.Count, "A").End(xlUp).Row To 2 Step -1
For k = 1 To 4
Cells(irow, "A").EntireRow.Insert
Next k
Next irow
End Sub

best wishes
--
Bernard V Liengme
Microsoft Excel MVP
http://people.stfx.ca/bliengme
remove caps from email

"Ranjit kurian" wrote in message
...
Hi

I have a column with few number, i need a macro code which will insert
4
rows after every number

example:
Amount
1
2
3
4
5
Answer:
1



2



3



4








All times are GMT +1. The time now is 08:37 AM.

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