ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to format cells to duplicate for every 5 rows. (https://www.excelbanter.com/excel-programming/399176-how-format-cells-duplicate-every-5-rows.html)

Alicia

How to format cells to duplicate for every 5 rows.
 
I am working on a sheet that already has ID numbers in column a. in the
format listed below. This goes on for about 300 rows

47846
47847

How can I format the sheet to look like this:
47846
47846
47846
47846
47846
47840
47840
47840
47840
47840
I need to list information in column b and c that corresponds to column a.
However, column a must contain the corresponding id number. Is there a way I
can automate this instead of doing it manually?

joel

How to format cells to duplicate for every 5 rows.
 
The macro below copies each row 4 times to give a total of 5 rows with each
id. Wasn't sure if you wanted entire row copies



Sub insert4rows()

LastRow = Cells(Rows.Count, "A").End(xlUp).Row
For RowCount = LastRow To 1 Step -1
Rows(RowCount).Copy
Rows(RowCount & ":" & (RowCount + 3)).Insert Shift:=xlDown
Next RowCount
End Sub




"Alicia" wrote:

I am working on a sheet that already has ID numbers in column a. in the
format listed below. This goes on for about 300 rows

47846
47847

How can I format the sheet to look like this:
47846
47846
47846
47846
47846
47840
47840
47840
47840
47840
I need to list information in column b and c that corresponds to column a.
However, column a must contain the corresponding id number. Is there a way I
can automate this instead of doing it manually?


Alicia

How to format cells to duplicate for every 5 rows.
 
This worked perfectly.

Thanks!

"Joel" wrote:

The macro below copies each row 4 times to give a total of 5 rows with each
id. Wasn't sure if you wanted entire row copies



Sub insert4rows()

LastRow = Cells(Rows.Count, "A").End(xlUp).Row
For RowCount = LastRow To 1 Step -1
Rows(RowCount).Copy
Rows(RowCount & ":" & (RowCount + 3)).Insert Shift:=xlDown
Next RowCount
End Sub




"Alicia" wrote:

I am working on a sheet that already has ID numbers in column a. in the
format listed below. This goes on for about 300 rows

47846
47847

How can I format the sheet to look like this:
47846
47846
47846
47846
47846
47840
47840
47840
47840
47840
I need to list information in column b and c that corresponds to column a.
However, column a must contain the corresponding id number. Is there a way I
can automate this instead of doing it manually?



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

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