Need macro that automatically inserts 12 rows, e.g. 12 lines items for each record

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
Some times doing things automatically has to have something to activate the script.
With this script if you enter data on a row when your done double click on Column(A) of the row with data and 12 copies of this row will be made below.
Now this script only copies values. If you need formatting also you will need to let me know.

This is an auto sheet event script
Your Workbook must be Macro enabled
To install this code:
Right-click on the sheet tab
Select View Code from the pop-up context menu
Paste the code in the VBA edit window
Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
'Modified 3-9-18 3:25 PM EST
Cancel = True
Dim ans As Long
ans = Target.Row
If Target.Column = 1 Then
If Target.Cells.Count > 1 Or IsEmpty(Target) Then Exit Sub
Rows(ans).Resize(12).Value = Rows(ans).Value
End If
End Sub
 
Upvote 0
If you need formatting also try this:
Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
'Modified With Formatting 3-9-18 3:50 PM EST
Cancel = True
Dim ans As Long
ans = Target.Row
If Target.Column = 1 Then
If Target.Cells.Count > 1 Or IsEmpty(Target) Then Exit Sub
Rows(ans).Copy Rows(ans).Resize(12)
End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,323
Members
452,635
Latest member
laura12345

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