VBA Macro for: Copying unique variables entered on one sheet automatically on to new worksheet?

slozcannon

New Member
Joined
Jun 7, 2023
Messages
8
Office Version
  1. 365
Platform
  1. Windows
Hi Everyone,

I have a workbook which has a master sheet and 5 secondary worksheets. More will be created with the same template going forward by date.

I need all data in secondary worksheets (column D of each one) to be copied in to worksheet 2 of the master sheet. Column D contains ID numbers.

I also need it to ONLY copy unique variables, so any repeated ID numbers get ignored.

Finally, I need i to offset to the next empty row, so it doesnt copy over existing data. Basically, as the weeks go by, any new ID numbers need to be copied in to the master copy, without duplicating or copying over whats already in the master sheet.

I managed to do these 2 subs so far but cant seem to combine the two? Can anyone please help?:
____________________________

Sub CopyStuff()

Range("X2:X12").Copy Sheets("Sheet1").Range("D" & Rows.Count).End(xlUp).Offset(1, 0)

End Sub
________________

Sub Unique_Values()

ThisWorkbook.Worksheets("08.06.2022").Activate
Range("D:D").AdvancedFilter Action:=xlFilterCopy, _
CopyToRange:=Range("X:X"), _
Unique:=True
Range("X2:X12").Copy Sheets("Sheet1").Range("D" & Rows.Count).End(xlUp).Offset(1, 0)

End Sub



____

Thanks alot!
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
Could also use a formula option, if you imagine that Columns A, C & E are in different sheets. It would aso depend on whether you have access to the TOCOL function:
Book1
ABCDEFGH
116121
216122
317133
427144
538155
648156
748167
849168
9510169
105111710
1111
1212
1313
1414
1515
1616
1717
Sheet1
Cell Formulas
RangeFormula
H1:H17H1=UNIQUE(VSTACK(TOCOL(A:A,1),TOCOL(C:C,1),TOCOL(E:E,1)))
Dynamic array formulas.
 
Upvote 0
Thanks man thats really helped me move it forward didnt think of that how creative, thank you
 
Upvote 0

Forum statistics

Threads
1,223,896
Messages
6,175,262
Members
452,627
Latest member
KitkatToby

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