VBA Copying data from sheet 1 to sheet 2 not including duplicates

Bobsta_666

New Member
Joined
Jan 15, 2024
Messages
14
Office Version
  1. 365
Platform
  1. Windows
I have a new problem....
I have a data sheet ("Sheet 1") with raw data, I want to filter/find based on Criteria ("billy") in column ("I"), how do I copy the data within range J2:W1000 based on that (criteria ("billy")) whilst removing blanks and only copying over rows to a new sheet ("Sheet 2") that do not find a match (are not duplicates).

The idea is - I have a data sheet ("Sheet 1") with exported jobs in, I want to bring over all the new jobs to the planning sheet ("Sheet 2") that do not already exist in the planning sheet ("Sheet 2"). The new jobs from ("Sheet 1") only need to add to the bottom of last inputted data of planning sheet ("Sheet 2") it does not need to remove anything from ("Sheet 2")

Consistent Data: in ("Sheet 1") column ("I"), I can use this column to filter/find the Criteria ("billy") for example as this contains common names that do not change
Then ("Sheet 1") Column ("S2:S1000") has a unique number that can be VLookup or Match to ("Sheet 2") column ("K4:K1000"), this can be used to determine whether the job already exists

copy Range ("Sheet 1") is J2:W1000 or (J2:W2 to last row)
paste Range ("Sheet 2") is B:O added to bottom of last row

Hope you find this an easy task because i have been pulling my hair out trying to partially write code and macro record to find a solution to no avail
thanks
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
Track Quality Planning -2024-2025 v2.xlsm
HIJKLMNOPQRSTUVW
1Attribute DescriptionSeverity DescriptionAttribute DescriptionPeakLocationPosition From ValueELRTIDTotal StartTotal endStandard Job NoActioned Work OrderFault IDLinespeedSuspected RepeatAction Due Date
2GaugeIntervention Limit - TrackGauge < 12 Weeks-20.39 51.48914:-0.14817VIR21000m824y0m824y0097097465993261753720N05/07/2023
3Track Quality SD Mean Alignment 35mVery Poor Eighth - TrackTrack Quality SD Mean Alignment 35m 4.27  VTB112007m660y7m880y00904875146525266385660N 
4Track Quality SD Mean Alignment 35mVery Poor Eighth - TrackTrack Quality SD Mean Alignment 35m 5.00  BBJ21006m440y6m660y00904875305641271205750N 
5Track Quality SD Mean Alignment 35mVery Poor Eighth - TrackTrack Quality SD Mean Alignment 35m 4.92  VTB112007m0y7m220y00904875328607271362860N 
6Track Quality SD Mean Alignment 35mVery Poor Eighth - TrackTrack Quality SD Mean Alignment 35m 6.81  BBJ21006m440y6m660y00904876098942280656650N 
7Track Quality SD Mean Alignment 35mVery Poor Eighth - TrackTrack Quality SD Mean Alignment 35m 6.51  VTB112001m1540y2m0y00904877812890287760145N 
8Track Quality SD Mean Alignment 35mVery Poor Eighth - TrackTrack Quality SD Mean Alignment 35m 6.40  VTB112002m1100y2m1320y00904877812891287760260N 
9Track Quality SD Mean Alignment 35mVery Poor Eighth - TrackTrack Quality SD Mean Alignment 35m 5.03  VTB112002m1540y3m0y00904877812892287760360N 
10Track Quality SD Mean Alignment 35mSuper Red - TrackTrack Quality SD Mean Alignment 35m 9.77  BSP221002m220y2m375y00904677812973288313325N 
11Track Quality SD Mean Alignment 35mVery Poor Eighth - TrackTrack Quality SD Mean Alignment 35m 5.50  VTB111006m220y6m440y00904877812893288313770N 
12Track Quality SD Mean Alignment 35mVery Poor Eighth - TrackTrack Quality SD Mean Alignment 35m 4.51  VIR21001m880y1m1100y00904877812894291333545N 
13Track Quality SD Mean Alignment 35mVery Poor Eighth - TrackTrack Quality SD Mean Alignment 35m 7.19  BBJ21006m440y6m660y00904877812895292066850N 
14Track Quality SD Mean Alignment 35mSuper Red - TrackTrack Quality SD Mean Alignment 35m 10.03  SLJ22006m143y6m220y00904677812974292074520N 
15Track Quality SD Mean Alignment 35mVery Poor Eighth - TrackTrack Quality SD Mean Alignment 35m 5.75  SLJ22006m220y6m440y00904877812896292074620N 
16Track Quality SD Worst Top 35mVery Poor Eighth - TrackTrack Quality SD Worst Top 35m 6.03  WLL11005m220y5m440y00904877812937292484360N 
17Track Quality SD Worst Top 35mSuper Red - TrackTrack Quality SD Worst Top 35m 6.37  WLL11005m660y5m880y00904677812984292484460N 
18Track Quality SD Worst Top 35mSuper Red - TrackTrack Quality SD Worst Top 35m 6.96  WLL11005m880y5m1100y00904677812985292484560N 
19Track Quality SD Worst Top 35mSuper Red - TrackTrack Quality SD Worst Top 35m 6.64  WLL11005m1100y5m1320y00904677812986292484660N 
Calculate
Cell Formulas
RangeFormula
H2:H19H2=HLOOKUP(Code!$A$10,Data!$A$1:$FK$1000,ROW(A2),FALSE)& ""
I2:I19I2=HLOOKUP(Code!$A$16,Data!$A$1:$FK$1000,ROW(A2),FALSE)
J2:J19J2=H2&" " &G2
K2:K19K2=HLOOKUP(Code!$A$12,Data!$A$1:$FK$1000,ROW(A2),FALSE)
L2:L19L2=""
M2:M19M2=IFERROR(HLOOKUP(Code!$A$15,Data!$A$1:$FK$1000,ROW(A2),FALSE),"")
N2:N19N2=HLOOKUP(Code!$A$8,Data!$A$1:$FK$1000,ROW(A2),FALSE)
O2:O19O2=HLOOKUP(Code!$A$9,Data!$A$1:$FK$1000,ROW(A2),FALSE)
P2:P19P2=B2&"m"&C2&"y"
Q2:Q19Q2=E2&"m"&F2&"y"
R2:R19R2=HLOOKUP(Code!$A$11,Data!$A$1:$FK$1000,ROW(A2),FALSE)
S2:S19S2=HLOOKUP(Code!$A$5,Data!$A$1:$FK$1000,ROW(A2),FALSE)
T2:T19T2=HLOOKUP(Code!$A$6,Data!$A$1:$FK$1000,ROW(A2),FALSE)
U2:U19U2=IFERROR(HLOOKUP(Code!$A$14,Data!$A$1:$FK$1000,ROW(A2),FALSE),"")
V2:V19V2=IFERROR(HLOOKUP(Code!$A$13,Data!$A$1:$FK$1000,ROW(A2),FALSE),"")
W2:W19W2=HLOOKUP(Code!$A$7,Data!$A$1:$FK$1000,ROW(A2),FALSE)
 
Upvote 0
this is ("Sheet 1") this sheet is named "Calculate"

Range from this to copy to "L2 Planning Sheet" is J2:W bottom of column

**Ignore the formula in cells**
 
Last edited:
Upvote 0
Track Quality Planning
0Description Of Work/Fault ValueLocationGPSELRTIDFault FromFault ToSTD NumberWork OrderTIGER IDSpeedRepeatDue DateTV DateCommentsWeek PlannedStatus
Gauge < 12 Weeks-20.3951.48914:-0.14817VIR21000m824y0m824y00970974659900261753720N05/07/2023
Gauge < 14 Days25.1751.46965:-0.15793CKL21002m468y2m468y00911776681331293061840N06/10/2023
Mean Alignment 35m < 4 Weeks-28.4151.47820:-0.14778VTB132001m446y1m446y00911577566599304827020N09/01/2024
Mean Alignment 35m < 4 Weeks29.7151.47833:-0.14779VTB132001m430y1m430y009115304827120N09/01/2024
Mean Alignment 35m < 4 Weeks43.0151.47877:-0.14778VTB132001m377y1m377y00911577566609304827320N09/01/2024
Mean Alignment 35m < 14 Days-21.7151.47828:-0.14776VTB111001m436y1m436y009115304832945N26/12/2023
Mean Alignment 35m < 4 Weeks-30.3551.42007:-0.13925SNS34006m872y6m872y00911577813078305690420N16/01/2024
Mean Alignment 35m < 4 Weeks41.3251.47033:-0.15696BSP221002m327y2m327y00911577813079305692625N16/01/2024
Cyclic Top 18m Right < 1 Month26.9751.47086:-0.15553BSP221002m201y2m219y00930877813112305695525N18/01/2024
Cyclic Top 18m Left < 1 Month26.2951.47086:-0.15553BSP221002m201y2m219y00930877813111305696225N18/01/2024
Cyclic Top 18m Both < 14 Days53.2551.47086:-0.15553BSP221002m201y2m219y00930877813110305696825N02/01/2024
Twist 3m < 14 Days-15.8551.47028:-0.16334SCC21003m883y3m883y00930877813103307554430N23/01/2024
Mean Alignment 35m < 4 Weeks23.7351.47030:-0.16356SCC21003m899y3m899y00911577813080307554530N06/02/2024
Mean Alignment 35m 7 Days-37.7451.49642:-0.20823WLL21003m713y3m713y00911577813081307554660N16/01/2024
Mean Alignment 35m < 14 Days41.3651.49651:-0.20837WLL35003m728y3m728y00911577813082307554725N23/01/2024
Mean Alignment 35m < 14 Days-29.4051.50033:-0.21308WLL35003m1314y3m1314y00911577813083307554825N23/01/2024
Mean Alignment 35m < 4 Weeks-22.4151.47096:-0.16844CJL11000m1486y0m1486y00911577813084307576220N06/02/2024
Mean Alignment 35m < 4 Weeks21.1751.47088:-0.16801CJL11000m1452y0m1452y00911577813085307576320N06/02/2024
Mean Alignment 35m 7 Days-37.7451.49642:-0.20823WLL21003m713y3m713y911577813081307554660N16/01/2024
Mean Alignment 35m 7 Days-37.7451.49642:-0.20823WLL21003m713y3m713y911577813081307554660N16/01/2024
Gauge < 12 Weeks-20.3951.48914:-0.14817VIR21000m824y0m824y0097097465993261753720N05/07/2023
 
Upvote 0
Range of "L2 Planning sheet" B:S, to be copied to the bottom of row as if adding new faults to list.
before copying faults from "calculate" to "L2 Planning Sheet" i want to filter out variables such as ("Super Red - Track") based on Sheet("calculate")Column (I)

And no duplicates to be copied over based on match of Sheet("calculate").Range(S2:onward) & Sheet("L2 Planning Sheet").Range(K4:onwards)

Sorry if i am confusing you :)
 
Upvote 0
OK

Let's back up a bit.

A few questions:
1. You want to copy data from the "Raw" sheet that doesn't exist in the production sheet based on some criteria.

Where are you searching for the criteria?

2. You need the raw data to not bring over blank rows, I didn't see any in the example above.

3. Is there any uniqueness to the row in Raw data, ie. a unique number or code?

What am I missing? I'm a bit confused but, would love to help.
 
Upvote 0
1. You want to copy data from the "Raw" sheet that doesn't exist in the production sheet based on some criteria.
The raw sheet I meant ("Calculate") sheet, there is a range in this sheet that is in the exact same order as the planning sheet ("L2 Planning Sheet") these are
("Calculate").Range("J2:W")
("L2 Planning Sheet").Range(B4:S)

These can be used to copy/paste


Where are you searching for the criteria?
The filter column in the ("Calculate") sheet (I) has the generic titles that can be used to filter what I require out of the data for example ("Super Red - Track")

2. You need the raw data to not bring over blank rows, I didn't see any in the example above.

The way I was doing it, was using filters to remove unwanted rows and then copying the range over to the ("L2 planning Sheet") but this was leaving all the blank cells still present.
So there is definitely a better way of transferring the information without copy and paste

3. Is there any uniqueness to the row in Raw data, ie. a unique number or code?


The Unique number that is in both sheets is located -
("Calculate").Range("S2:Bottom")
("L2 Planning Sheet").Range("K4:Bottom)

The work order number in these cells can determine whether it already exists in


What am I missing? I'm a bit confused but, would love to help.

Sorry i was jumping the Gun, thanks for the help
 
Upvote 0

Forum statistics

Threads
1,224,816
Messages
6,181,139
Members
453,021
Latest member
Justyna P

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