VBA - Applying Autofill with inserted rows (based on input box) and apply it to other sheet

Status
Not open for further replies.

Jeofbist3

New Member
Joined
Jun 13, 2017
Messages
16
Hello everyone!

I have a macro that add news rows based on a input userbox and I'd like to use the autofill to keep the formulas and also same layout if possible.

Example: I want to add 4 extra products in sheet1. Now, the macro (my button) creates 4 new rows below row #24 (Product1), row #28, and row #32. I want to apply the original formulas in columns O, AB, AO, BB and BO to the new inserted rows. How can I adapt the following code?

VBA Code:
Sub NewPoS()

Application.ScreenUpdating = False
Dim MyN As String
Dim i As Long, MyMarker As Long, MyM As Long, LstRW As Long
Dim ws As Worksheet: Set ws = Feuil1

MyN = InputBox("Give me a number", "My Input Box")
If Not IsNumeric(MyN) Then Exit Sub
MyN = CInt(MyN)
For MyMarker = 1 To 5
LstRW = ws.Cells(ws.Rows.Count, 1).End(xlUp).Row
MyM = Application.Match("Marker" & MyMarker, ws.Range(ws.Cells(1, 1), ws.Cells(LstRW, 1)), 0)
    For i = 1 To MyN
        ws.Rows(MyM + 2).EntireRow.Insert shift:=xlUp
    Next i
Next MyMarker

End Sub

Besides, I want to do the exact same thing on sheet2, but in which values of cells are the same as sheet1 (as already set)

Thanks for your help!
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
Cross post VBA - Applying Autofill with inserted rows (based on input box) and apply it to other sheet - OzGrid Free Excel/VBA Help Forum

While we do allow Cross-Posting on this site, we do ask that you please mention you are doing so and provide links in each of the threads pointing to the other thread (see rule 13 here along with the explanation: Forum Rules). This way, other members can see what has already been done in regards to a question, and do not waste time working on a question that may already be answered.
 
Upvote 0
Hi, alright. Here is the initial thread:
 
Upvote 0
As it happens I was not referring to your duplicate, but now that you have pointed that out.
Please do not post the same question multiple times. All clarifications, follow-ups, and bumps should be posted back to the original thread. Per forum rules, posts of a duplicate nature will be locked or deleted (rule 12 here: Forum Rules).

Please take the time to read our rules.
 
Upvote 0
Status
Not open for further replies.

Forum statistics

Threads
1,214,518
Messages
6,119,985
Members
448,935
Latest member
ijat

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