Automate insertion of row data

MrJJP

New Member
Joined
Sep 9, 2024
Messages
3
Office Version
  1. 365
Platform
  1. Windows
Hello, would like to automatically add certain row data when data in other cells is added. In the below screenshot I have unchanging data in columns B & C, with the expectation that users will input data into the respective columns D, E & F. So my starting point in the example is B2:F5, and I would like it to come out to looking like the example in B8:F13. Another way to say this, is in B8:F13, if a user input the data into D8, E8, and/or F8, upon hitting enter, it would create a new row underneath it with blanks (ready for the next user's input) into D9:F9, but still copy/retain the original data values from B8 and C8. I'd prefer to do it without VBA, but can muster through that with any additional help (my total number of rows will be around 35 and I may have 3-4 additional columns). Thanks for any help!

1725913926851.png
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
You can't do it without VBA because it's not possible to change a worksheet structure with formulas (i.e. insert rows etc). So to that end:
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    Dim cRow As Long
    If Intersect(Target, Range("D3:F40")) Is Nothing Then Exit Sub
    Application.EnableEvents = False
    cRow = Target.Row
    Range("B" & cRow & ":C" & cRow).Copy
    Range("B" & cRow + 1).Insert Shift:=xlDown
    Application.CutCopyMode = False
    Application.EnableEvents = True
End Sub

This code needs to go in the Worksheet_Change event of your worksheet. To do that open the VBA editor (ALT+F11) and on the left hand side right-click on the sheet you're working in and click View Code. Then paste the code in the window that appears.
1723617106577.png
 
Upvote 0
Thanks for the assistance, very much appreciated! It's working in part but there is an issue though I think I figured out solution. So the issue that I was facing is when I place my cursor in the "Date" column (D), enter a date, and then press tab to enter data into the "Participants" column, it would add a row, and then when I would tab to the "POC" (F) column, it would add yet another row. What I did, and please tell me if this will work (it did on my test run, but want to be wary of any potential issues), is I changed the 3rd line of the code for the "(Target, Range("F3:F40")..." so only when a value in column F is added, will it add a duplicate row.
Also, I added a few extra columns in my final sheet to be copied, so instead of just columns B and C, it's B, C, D. I think I would just change the 6th line of code from "C" to "D"? Thanks again!!
 
Upvote 0

Forum statistics

Threads
1,221,417
Messages
6,159,786
Members
451,589
Latest member
Harold14

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