Insert line, sequential/auotfill number and keep formatting

wilson187

New Member
Joined
Jul 14, 2017
Messages
7
Hi everyone,

I am looking to produce a macro that will enable me to do the following:

Copy a selection of cells, for instance [A6:D6]
Insert the same row; in terms of formatting and row height into [A7:D7]

However, cell A6, contains the following data "a.1" and when the macro is run, cell A7 would be automatically populated with "a.2", so on and so forth.... cell A8 would be populated with "a.3"

Any help or suggestions would be greatly appreciated!

Many thanks
-Gary
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
You want to copy values and formatting from A6:D6 to how many rows while incrementing the col A entry's suffix number by 1 in each row?
 
Upvote 0
Hi Joe,

I would like to copy just one row at a time. So after copying a6:d6 to a7:d7, the macro would then copy a7:d7 to a8:d8 so on and so forth so a7.d7 would auto populate to "a.2" and a8:d8 to "a.3". I have a picture/snapshot to show but am unsure how to upload it to show you?

hope this helps.

-Gary
 
Upvote 0
Hi Joe,

I would like to copy just one row at a time. So after copying a6:d6 to a7:d7, the macro would then copy a7:d7 to a8:d8 so on and so forth so a7.d7 would auto populate to "a.2" and a8:d8 to "a.3". I have a picture/snapshot to show but am unsure how to upload it to show you?

hope this helps.

-Gary
Your first sentence says you want to copy one row to the row below it. But, you then say you want that to continue ... so on and so forth. Do you want to simply run the macro again for the continuation or do you want the macro to continue on after the first row is copied? If the latter, then you need to tell us where - which row - you want the macro to stop copying.
 
Upvote 0
Your first sentence says you want to copy one row to the row below it. But, you then say you want that to continue ... so on and so forth. Do you want to simply run the macro again for the continuation or do you want the macro to continue on after the first row is copied? If the latter, then you need to tell us where - which row - you want the macro to stop copying.

To run the macro again for continuation.

Thanks
 
Upvote 0
To run the macro again for continuation.

Thanks
See if this works for you.
Code:
Sub InsertCopiedRow()
Const Cols As Long = 4 '<-- set the number of columns you want to copy here. 4 would be A:D
Dim lR As Long
lR = Range("A" & Rows.Count).End(xlUp).Row
With Range("A" & lR).Resize(1, Cols)
    .Offset(1, 0).EntireRow.Insert
    .Copy Destination:=.Offset(1, 0)
    .Cells(1, 1).AutoFill Destination:=.Cells(1, 1).Resize(2, 1), Type:=xlFillDefault
End With
End Sub
 
Upvote 0
Any additional code so that cells in A column remain populated but cells in B, C & D are inserted as blanks?

-Gary
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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