Hi - I'm trying to set up a macro that will allow me to move new data rows to another spreadsheet. I'll be pasting the latest report into a worksheet (cvent21). This is will have new registrants added at the bottom of the list. I want the latest new registrants' data to append to the bottom of another worksheet (2021). Though I only want certain columns to copy over. I've tried to teach myself how to do this, but haven't managed it, I'm not up to speed with VBA. Any help appreciated I've attached a sample filerolling-rev-test1.xlsx
Append new data rows (selected columns only) from one worksheet to another
- jlw-energy
- Thread is marked as Resolved.
-
-
-
Hello JLW-E,
See if the following code does the trick for you (untested):-
Code
Display MoreOption Explicit Sub Test() Dim sh As Worksheet, wsD As Worksheet, i As Long, nrow As Long Dim ClArr As Variant, pArr As Variant Set sh = Sheets("cvent21") Set wsD = Sheets("2021") ClArr = Array(4, 21, 22, 23, 3, 24, 14, 19, 9) pArr = Array("A", "B", "C", "D", "E", "F", "G", "H", "L") nrow = wsD.Cells(Rows.Count, 1).End(xlUp).Row + 1 Application.ScreenUpdating = False With sh.[A1].CurrentRegion .AutoFilter 26, "Y" With .Offset(1) For i = LBound(ClArr) To UBound(ClArr) .Columns(ClArr(i)).Copy wsD.Range(pArr(i) & nrow) Next i End With .AutoFilter wsD.Columns.AutoFit End With Application.ScreenUpdating = True End Sub
I've added a simple criteria column(Z) to determine if an entry is a new registrant. Place a "Y" in a cell and the code will do the rest.
I hope that this helps.
Cheerio,
vcoolio.
-
Hi Vcoolio - thanks very much for that, I'm not too sure what you did, but it worked for me! I'm very grateful
-
Hello JLW-E,
You're welcome. I'm glad to have been able to assist.
Cheerio,
vcoolio.
Participate now!
Don’t have an account yet? Register yourself now and be a part of our community!