Comparing two sheets and adding in new data?

afc171

Board Regular
Joined
Jan 14, 2017
Messages
145
Office Version
  1. 2013
Platform
  1. Windows
Hi all,
I am trying to compare two sheets and copy the new data from 1 to another if its not there, this code only seems to copy the first 2 columns.
What do I need to change to include up to column I? Also is there a way to copy them to Compare sheet with a different colour to see what has been added?

VBA Code:
Sub Compare()
   Dim Ary As Variant
   Dim i As Long, j As Long
   
   Ary = Sheets("RECP1").Range("A1").CurrentRegion.Value2
   With Sheets("Compare")
      j = .Range("A" & Rows.Count).End(xlUp).Row
      For i = UBound(Ary) To 2 Step -1
         If .Cells(j, 1).Value = Ary(i, 1) Then
            j = j - 1
         Else
            Rows(j + 1).Insert
            .Cells(j + 1, 1).Resize(, 2).Value = Array(Ary(i, 1), Ary(i, 2))
         End If
      Next i
   End With
End Sub

Thank you
 
Ok so I changed the headers around but for some reason its not picking up some stuff correctly:

LC Stock Check SageVStatic.xlsm
ABCDEFGHIJKLMNOP
1productdescriptionlot_numberbin_numberquantityexpiry_datewhsproductdescriptionlot_numberbin_numberquantityexpiry_datewhs
212004272Cytometer Cleaner64469722LC26203/Mar/24LC12004272Cytometer Cleaner64469722LC26203/Mar/24LC
312004403ZE Series QC Bead01M-052621LCLAB28226/May/24LC12004403ZE Series QC Bead01M-052621LCLAB28226/May/24LC
41351118VIVAFIX 649/6602810132LCLAB201119/Nov/23LC1351118VIVAFIX 649/6602810132LCLAB201119/Nov/23LC
51450016COUNTING SLIDES64480964LC265LC1450016COUNTING SLIDES64480964LC265LC
61610393PRECISION ALL BLUE64456132LCLAB201203/Dec/23LC1610393PRECISION ALL BLUE64456132LCLAB201203/Dec/23LC
71610393PRECISION ALL BLUE64463382LCLAB201304/Feb/24LC1610393PRECISION ALL BLUE64463382LCLAB201304/Feb/24LC
81610396UNSTAINED PROTEIN64495841LCLAB201207/Jul/24LC1610396UNSTAINED PROTEIN64495841LCLAB201207/Jul/24LC
91610610DITHIOTHREITOL (DTT)64434521LCLAB28230/Jul/23LC1610610DITHIOTHREITOL (DTT)64434521LCLAB28230/Jul/23LC
101610737LAEMMLI SAMPLE BUFF64439662LC26110/Sep/23LC1610737LAEMMLI SAMPLE BUFF64439662LC26110/Sep/23LC
111610737LAEMMLI SAMPLE BUFF64476022LC26230/Apr/24LC1610737LAEMMLI SAMPLE BUFF64476022LC26230/Apr/24LC
121610747LAEMMLI SAMPLE BUFF64495266LC17102/Jun/24LC1610747LAEMMLI SAMPLE BUFF64495266LC17102/Jun/24LC
131610772TGS (10x)64486547LC17120/May/23LC1610772TGS (10x)64486547LC17120/May/23LC
141610772TGS (10x)64486547LC17220/May/23LC1610772TGS (10x)64486547LC17220/May/23LC
151610782TBS 1% CASEIN BLOCKI64467967LCLAB28130/Jan/27LC1610782TBS 1% CASEIN BLOCKI64467967LCLAB28130/Jan/27LC
161610782TBS 1% CASEIN BLOCKI64473954LCLAB28223/Feb/27LC1610782TBS 1% CASEIN BLOCKI64473954LCLAB28223/Feb/27LC
171704157PVDF TRANSBLOT64465952LCLAB28311/Aug/23LC1704157PVDF TRANSBLOT64465952LCLAB28311/Aug/23LC
181704159MIDI NITROCELLULOSE64455211LCLAB28726/Jan/23LC1704159MIDI NITROCELLULOSE64455211LCLAB28726/Jan/23LC
195678084CRITERION 4-15% TGX64488214BULK0022023/May/23LC5678084CRITERION 4-15% TGX64488214BULK0022023/May/23LC
205678084CRITERION 4-15% TGX64488214BULK0022023/May/23LC5678084CRITERION 4-15% TGX64488214BULK0022023/May/23LC
215678084CRITERION 4-15% TGX64493591BULK0022022/Jun/23LC5678084CRITERION 4-15% TGX64493591BULK0022022/Jun/23LC
225678084CRITERION 4-15% TGX64493591BULK002622/Jun/23LC5678084CRITERION 4-15% TGX64493591BULK002622/Jun/23LC
235678084CRITERION 4-15% TGX64501702BULK002901/Aug/23LC5678084CRITERION 4-15% TGX64501702BULK002901/Aug/23LC
245678084CRITERION 4-15% TGX64497384BULK0021611/Jul/23LC5678084CRITERION 4-15% TGX64497384BULK0021611/Jul/23LC
255678124ANY KD CRITERION TGX64491863BULK0021416/Jun/23LC5678124ANY KD CRITERION TGX64491863BULK0021416/Jun/23LC
265678124ANY KD CRITERION TGX64491863BULK0022916/Jun/23LC5678124ANY KD CRITERION TGX64491863BULK0022916/Jun/23LC
275678124ANY KD CRITERION TGX64496756BULK0021207/Jul/23LC5678124ANY KD CRITERION TGX64496756BULK0021207/Jul/23LC
285678124ANY KD CRITERION TGX64501740BULK0021802/Aug/23LC5678124ANY KD CRITERION TGX64501740BULK0021802/Aug/23LC
295678124ANY KD CRITERION TGX64501740BULK0023402/Aug/23LC5678124ANY KD CRITERION TGX64501740BULK0023402/Aug/23LC
30CHE0006MYCOALERT ASSAY0001103247LCLAB28322/Sep/23LCCHE0006MYCOALERT ASSAY0001103247LCLAB28322/Sep/23LC
31CHE0006MYCOALERT ASSAY0001152492LCLAB28403/May/24LCCHE0006MYCOALERT ASSAY0001152492LCLAB28403/May/24LC
32CHE0007MYCOALERT + DET KIT200422LCLAB28125/May/23LCCHE0007MYCOALERT + DET KIT200422LCLAB28125/May/23LC
33CHE0007MYCOALERT + DET KIT14-JUL-202LCLAB28414/Jul/23LCCHE0007MYCOALERT + DET KIT14-JUL-202LCLAB28414/Jul/23LC
34CHE0009CONCANAVALIN ASLCC7678LCLAB2011LCCHE0009CONCANAVALIN ASLCC7678LCLAB2011LC
35CHE0012IONOMYCIN109M4048VLCLAB281LCCHE0012IONOMYCIN109M4048VLCLAB281LC
36CHE0013PMASLBX8889LCLAB2011LCCHE0013PMASLBX8889LCLAB2011LC
37CHE0014SHEATH FLUID2210409811LC20114/Apr/25LCCHE0014SHEATH FLUID2210409811LC20114/Apr/25LC
38CHE0014SHEATH FLUID2218809812LC20507/Jul/25LCCHE0014SHEATH FLUID2218809812LC20507/Jul/25LC
39CHE0015PHA-PSLCC9870LCLAB281LCCHE0015PHA-PSLCC9870LCLAB281LC
40CHE0016FACS CLEAN SOLUTION2135709817LC103LCCHE0016FACS CLEAN SOLUTION2135709817LC103LC
41CHE0020HUMAN SERUMSLCF0691LCLAB2012LCCHE0020HUMAN SERUMSLCF0691LCLAB2012LC
42CHE0023ACUITY ADVANCEDB365554LCLAB281LCCHE0023ACUITY ADVANCEDB365554LCLAB281LC
43CHE0023ACUITY ADVANCEDB372951LCLAB28103/Jun/24LCCHE0023ACUITY ADVANCEDB372951LCLAB28103/Jun/24LC
44CHE0024CHROMOGEN CONCENTRATB356871LCLAB28119/Sep/23LCCHE0024CHROMOGEN CONCENTRATB356871LCLAB28119/Sep/23LC
45CHE0025DAB SUBSTRATE BUFFERB355289LCLAB28211/Dec/23LCCHE0025DAB SUBSTRATE BUFFERB355289LCLAB28211/Dec/23LC
46CHE0026STEMPRO ACCUTASE CEL2M2635ALCLAB201631/Jan/24LCCHE0026STEMPRO ACCUTASE CEL2M2635ALCLAB201631/Jan/24LC
47CHE0026STEMPRO ACCUTASE CEL2N0238ALCLAB201428/Feb/24LCCHE0026STEMPRO ACCUTASE CEL2N0238ALCLAB201428/Feb/24LC
48CHE0026STEMPRO ACCUTASE CEL2310199LCLAB2011028/Feb/24LCCHE0026STEMPRO ACCUTASE CEL2310199LCLAB2011028/Feb/24LC
49CHE0028TC GRADE DMSORNBL1421LC17231/May/24LCCHE0028TC GRADE DMSORNBL1421LC17231/May/24LC
50CHE0029NON ESS AMINO ACIDS2511916LCLAB28431/Dec/23LCCHE0029NON ESS AMINO ACIDS2511916LCLAB28431/Dec/23LC
51CHE0029NON ESS AMINO ACIDS2512133LCLAB284528/Feb/24LCCHE0029NON ESS AMINO ACIDS2512133LCLAB284528/Feb/24LC
52CHE0030L-GLUTAMINE 200MM2512068FC3031/Jan/24LCCHE0030L-GLUTAMINE 200MM2512068FC3031/Jan/24LC
53CHE0031D GLUCOSE SOLUTIONRNBL1222LCLAB2810LCCHE0031D GLUCOSE SOLUTIONRNBL1222LCLAB2810LC
54CHE0031D GLUCOSE SOLUTIONRNBL1222LCLAB2827LCCHE0031D GLUCOSE SOLUTIONRNBL1222LCLAB2827LC
55CHE0033SODIUM PYRUVATE2511572LCLAB284531/Jul/23LCCHE0033SODIUM PYRUVATE2511572LCLAB284531/Jul/23LC
56CHE0040MYCOPLASMA OFF LIQUI150M22C1LC14COSH331/Aug/23LCCHE0040MYCOPLASMA OFF LIQUI150M22C1LC14COSH331/Aug/23LC
57CHE0040MYCOPLASMA OFF LIQUI150M22F1LC14COSH431/Dec/23LCCHE0040MYCOPLASMA OFF LIQUI150M22F1LC14COSH431/Dec/23LC
58CHE0042SHEATH FILTER ASSEMB280421LC102LCCHE0042SHEATH FILTER ASSEMB280421LC102LC
59CHE0044LPS0000112732LCLAB281LCCHE0044LPS0000112732LCLAB281LC
60CHE0045QUICK COOMASSIE74PT20220+BULK0026LCCHE0045QUICK COOMASSIE74PT20220+BULK0026LC
61CHE0045QUICK COOMASSIE77PT22080+BULK0021LCCHE0045QUICK COOMASSIE77PT22080+BULK0021LC
62CHE0045QUICK COOMASSIE77PT220801BULK0028LCCHE0045QUICK COOMASSIE77PT220801BULK0028LC
63CHE0048A7906-100G BSASLCK4304LCLAB288LCCHE0048A7906-100G BSASLCK4304LCLAB288LC
64CHE0048A7906-100G BSASLCM1122LCLAB287LCCHE0048A7906-100G BSASLCM1122LCLAB287LC
65CHE0049CS&T RESEARCH BEADS20458LCLAB28129/Feb/24LCCHE0049CS&T RESEARCH BEADS20458LCLAB28129/Feb/24LC
66CHE0050Hematoxylin QSZJ0527LC32131/May/24LCCHE0050Hematoxylin QSZJ0527LC32131/May/24LC
67CHE0051Fetal Bovine Serum2528413RPLCLAB201230/Jun/27LCCHE0051Fetal Bovine Serum2528413RPLCLAB201230/Jun/27LC
68CON0001CENTRIFUGE16221006LC191LCCON0001CENTRIFUGE16221006LC191LC
69CON0001CENTRIFUGE19021003LC193LCCON0001CENTRIFUGE19021003LC193LC
70CON0001CENTRIFUGE17122006LC193LCCON0001CENTRIFUGE17122006LC193LC
71CON0002SCREWCAP20368LC13128/Mar/31LCCON0002SCREWCAP20368LC13128/Mar/31LC
72CON0002SCREWCAP22138LC132LCCON0002SCREWCAP22138LC132LC
73CON0003SCREWCAP20475LC13228/Mar/31LCCON0003SCREWCAP20475LC13228/Mar/31LC
74CON0004SCREW CAP21285LC131LCCON0004SCREW CAP21285LC131LC
75CON0004SCREW CAP21285LC132LCCON0004SCREW CAP21285LC132LC
76CON0006SCREWCAP21375LC131LCCON0006SCREWCAP21375LC131LC
77CON0006SCREWCAP21415LC132LCCON0006SCREWCAP21415LC132LC
78CON000775CM TC FLASKS10023863LC16227/Apr/24LCCON000775CM TC FLASKS10023863LC16227/Apr/24LC
79CON000775CM TC FLASKS100026093LC16212/May/25LCCON000775CM TC FLASKS100026093LC16212/May/25LC
80CON0008850cm ROLLER BOTTLE1336103LC25426/Oct/23LCCON0008850cm ROLLER BOTTLE1336103LC25426/Oct/23LC
81CON0009175CM TC FLASKS55519LC21108/Jul/28LCCON0009175CM TC FLASKS55519LC21108/Jul/28LC
82CON0009175CM TC FLASKS5000397LC21223/Feb/23LCCON0009175CM TC FLASKS5000397LC21223/Feb/23LC
83CON0010175CM TC FLASKS2101604LC25229/Mar/27LCCON0010175CM TC FLASKS2101604LC25229/Mar/27LC
84CON0010175CM TC FLASKS2101004LC25428/Feb/27LCCON0010175CM TC FLASKS2101004LC25428/Feb/27LC
85CON0010175CM TC FLASKS2004007LC25429/Dec/26LCCON0010175CM TC FLASKS2004007LC25429/Dec/26LC
86CON0010175CM TC FLASKS2004007LC25429/Dec/26LCCON0010175CM TC FLASKS2004007LC25429/Dec/26LC
87CON0010175CM TC FLASKS2090103LC25429/Mar/27LCCON0010175CM TC FLASKS2090103LC25429/Mar/27LC
88CON0010175CM TC FLASKS2091013LC25229/Mar/27LCCON0010175CM TC FLASKS2091013LC25229/Mar/27LC
89CON0010175CM TC FLASKS2096003LC25229/Mar/27LCCON0010175CM TC FLASKS2096003LC25229/Mar/27LC
90CON0011SMALL TISSUE CULTURE10024905-+LC24207/Feb/25LCCON0011SMALL TISSUE CULTURE10024905-+LC24207/Feb/25LC
91CON0011SMALL TISSUE CULTURE100026353+LC24226/May/25LCCON0011SMALL TISSUE CULTURE100026353+LC24226/May/25LC
92CON0012MEDIUM TC FLASKS100024905+LC16116/Feb/25LCCON0012MEDIUM TC FLASKS100024905+LC16116/Feb/25LC
93CON0012MEDIUM TC FLASKS100025382+LC16224/Mar/25LCCON0012MEDIUM TC FLASKS100025382+LC16224/Mar/25LC
94CON0013500ML PP CENTRIFUGE22522020LC20213/Aug/25LCCON0013500ML PP CENTRIFUGE22522020LC20213/Aug/25LC
95CON0013500ML PP CENTRIFUGE20522017LC20224/Jul/25LCCON0013500ML PP CENTRIFUGE20522017LC20224/Jul/25LC
96CON001460ML NALGENE BOTTLES1318451LC284LCCON001460ML NALGENE BOTTLES1318451LC284LC
97CON0015125ML NALGENE BOTTLE1321408LC301LCCON0015125ML NALGENE BOTTLE1321408LC301LC
98CON0015125ML NALGENE BOTTLE1321408LC304LCCON0015125ML NALGENE BOTTLE1321408LC304LC
99CON001650ML CENTRIFUGE TUBE27021035LC34226/Sep/26LCCON001650ML CENTRIFUGE TUBE27021035LC34226/Sep/26LC
100CON001650ML CENTRIFUGE TUBE28421094LC34212/Oct/26LCCON001650ML CENTRIFUGE TUBE28421094LC34212/Oct/26LC
101CON0017500ML NALGENE BOTTLE1219853LC31106/Jul/28LCCON0017500ML NALGENE BOTTLE1219853LC31106/Jul/28LC
102CON0017500ML NALGENE BOTTLE1225550LC31123/Sep/29LCCON0017500ML NALGENE BOTTLE1225550LC31123/Sep/29LC
103CON0018250ML NALGENE BOTTLE1253162LC31230/Jun/29LCCON0018250ML NALGENE BOTTLE1253162LC31230/Jun/29LC
104CON001915ML CENTRIFUGE TUBE27521032LC33201/Oct/26LCCON001915ML CENTRIFUGE TUBE27521032LC33201/Oct/26LC
105CON001915ML CENTRIFUGE TUBE30521044LC33130/Oct/26LCCON001915ML CENTRIFUGE TUBE30521044LC33130/Oct/26LC
106CON001915ML CENTRIFUGE TUBE30521044LC33131/Oct/26LCCON001915ML CENTRIFUGE TUBE30521044LC33131/Oct/26LC
107CON001915ML CENTRIFUGE TUBE14622046LC33125/May/27LCCON001915ML CENTRIFUGE TUBE14622046LC33125/May/27LC
108CON001915ML CENTRIFUGE TUBE00322040LC33101/Mar/27LCCON001915ML CENTRIFUGE TUBE00322040LC33101/Mar/27LC
109CON001915ML CENTRIFUGE TUBE00322040LC33303/Jan/27LCCON001915ML CENTRIFUGE TUBE00322040LC33303/Jan/27LC
110CON001915ML CENTRIFUGE TUBE00322040LC33103/Jan/27LCCON001915ML CENTRIFUGE TUBE00322040LC33103/Jan/27LC
111CON00201 LITRE NALGEN BOTTL1399905LC32229/Jul/29LCCON00201 LITRE NALGEN BOTTL1399905LC32229/Jul/29LC
112CON00201 LITRE NALGEN BOTTL1325575LC322LCCON00201 LITRE NALGEN BOTTL1325575LC322LC
113CON00212ML CRYOVIALS INTERN170115LC11131/Jul/26LCCON00212ML CRYOVIALS INTERN170115LC11131/Jul/26LC
114CON00212ML CRYOVIALS INTERN173088LC11231/May/27LCCON00212ML CRYOVIALS INTERN173088LC11231/May/27LC
115CON00221.5ML MICROCENTRIFUG22102079LC142LCCON00221.5ML MICROCENTRIFUG22102079LC142LC
116CON00221.5ML MICROCENTRIFUG22102079LC145LCCON00221.5ML MICROCENTRIFUG22102079LC145LC
117CON0023MICROCENTRIFUGE TUBE20P1023102LC14431/Jul/30LCCON0023MICROCENTRIFUGE TUBE20P1023102LC14431/Jul/30LC
118CON0023MICROCENTRIFUGE TUBE20P1032102LC144LCCON0023MICROCENTRIFUGE TUBE20P1032102LC144LC
119CON002410ml Tube801188LC341LCCON002410ml Tube801188LC341LC
120CON002410ml Tube821341LC342LCCON002410ml Tube821341LC342LC
121CON002410ml Tube822970LC344LCCON002410ml Tube822970LC344LC
122CON002530ML NALGENE BOTTLES1270094LC293LCCON002530ML NALGENE BOTTLES1270094LC293LC
123CON002530ML NALGENE BOTTLES120094LC292LCCON002530ML NALGENE BOTTLES120094LC292LC
124CON00280.5ML NATURAL VIALS1352492LC332LCCON00280.5ML NATURAL VIALS1352492LC332LC
125CON00280.5ML NATURAL VIALS1352492LC334LCCON00280.5ML NATURAL VIALS1352492LC334LC
126CON00280.5ML NATURAL VIALS1352492LC334LCCON00280.5ML NATURAL VIALS1352492LC334LC
127CON00280.5ML NATURAL VIALS1352492LC334LCCON00280.5ML NATURAL VIALS1352492LC334LC
128CON00280.5ML NATURAL VIALS1352492LC334LCCON00280.5ML NATURAL VIALS1352492LC334LC
129CON00280.5ML NATURAL VIALS1352492LC334LCCON00280.5ML NATURAL VIALS1352492LC334LC
130CON00292ML NATURAL VIALS1321354LC11LCCON00292ML NATURAL VIALS1321354LC11LC
131CON00292ML NATURAL VIALS1321935LC13LCCON00292ML NATURAL VIALS1321935LC13LC
132CON00292ML NATURAL VIALS1321935LC19LCCON00292ML NATURAL VIALS1321935LC19LC
133CON00300.5ML AMBER VIALS1276403LC12LCCON00300.5ML AMBER VIALS1276403LC12LC
134CON00300.5ML AMBER VIALS1272844LC13LCCON00300.5ML AMBER VIALS1272844LC13LC
135CON00300.5ML AMBER VIALS1327524LC11LCCON00300.5ML AMBER VIALS1327524LC11LC
136CON00300.5ML AMBER VIALS1343242LC13LCCON00300.5ML AMBER VIALS1343242LC13LC
137CON00300.5ML AMBER VIALS1332812LC15LCCON00300.5ML AMBER VIALS1332812LC15LC
138CON00312ML AMBER VIALS1349099LC11LCCON00312ML AMBER VIALS1349099LC11LC
139CON00312ML AMBER VIALS1349099LC14LCCON00312ML AMBER VIALS1349099LC14LC
140CON0032NATURAL CLOSURE1342762LC31LCCON0032NATURAL CLOSURE1342762LC31LC
141CON0032NATURAL CLOSURE1342762LC33LCCON0032NATURAL CLOSURE1342762LC33LC
142CON0032NATURAL CLOSURE1349473LC32LCCON0032NATURAL CLOSURE1349473LC32LC
143CON0032NATURAL CLOSURE1349473LC35LCCON0032NATURAL CLOSURE1349473LC35LC
144CON0032NATURAL CLOSURE1349473LC34LCCON0032NATURAL CLOSURE1349473LC34LC
145CON0032NATURAL CLOSURE1349473LC31LCCON0032NATURAL CLOSURE1349473LC31LC
146CON0032NATURAL CLOSURE1349473LC35LCCON0032NATURAL CLOSURE1349473LC35LC
147CON0032NATURAL CLOSURE1360216LC35LCCON0032NATURAL CLOSURE1360216LC35LC
148CON0036AMBER CLOSURE1311963LC31LCCON0036AMBER CLOSURE1311963LC31LC
149CON0036AMBER CLOSURE1311963LC32LCCON0036AMBER CLOSURE1311963LC32LC
150CON0036AMBER CLOSURE1311963LC32LCCON0036AMBER CLOSURE1311963LC32LC
151CON0036AMBER CLOSURE1311963LC32LCCON0036AMBER CLOSURE1311963LC32LC
152CON0036AMBER CLOSURE1354026LC31LCCON0036AMBER CLOSURE1354026LC31LC
153CON0036AMBER CLOSURE1354026LC31LCCON0036AMBER CLOSURE1354026LC31LC
154CON0036AMBER CLOSURE1354026LC31LCCON0036AMBER CLOSURE1354026LC31LC
155CON0036AMBER CLOSURE1354026LC32LCCON0036AMBER CLOSURE1354026LC32LC
156CON003715.5MM WADLESS CAPS031123LC27414/Jun/25LCCON003715.5MM WADLESS CAPS031123LC27414/Jun/25LC
157CON003715.5MM WADLESS CAPS033612LC275LCCON003715.5MM WADLESS CAPS033612LC275LC
158CON003715.5MM WADLESS CAPS040660LC27114/Jan/27LCCON003715.5MM WADLESS CAPS040660LC27114/Jan/27LC
159CON003822MM WADLESS CAPS011133LC27102/Jul/28LCCON003822MM WADLESS CAPS011133LC27102/Jul/28LC
160CON003822MM WADLESS CAPS033270LC271LCCON003822MM WADLESS CAPS033270LC271LC
161CON003822MM WADLESS CAPS038900LC272LCCON003822MM WADLESS CAPS038900LC272LC
162CON003915MM RUBBER STOPPERS036061LC281LCCON003915MM RUBBER STOPPERS036061LC281LC
163CON003915MM RUBBER STOPPERS043329LC28320/May/27LCCON003915MM RUBBER STOPPERS043329LC28320/May/27LC
164CON004022MM RUBBER STOPPERS14194LC28112/Nov/27LCCON004022MM RUBBER STOPPERS14194LC28112/Nov/27LC
165CON004022MM RUBBER STOPPERS026471LC28106/May/25LCCON004022MM RUBBER STOPPERS026471LC28106/May/25LC
166CON0041CLEAR GLASS VIALS18183LC29124/Mar/31LCCON0041CLEAR GLASS VIALS18183LC29124/Mar/31LC
167CON0041CLEAR GLASS VIALS18183LC291LCCON0041CLEAR GLASS VIALS18183LC291LC
168CON004250ML GLASS VIAL10538LC294LCCON004250ML GLASS VIAL10538LC294LC
169CON00433ML AMBER GLASSP0050134LC5220/Jun/27LCCON00433ML AMBER GLASSP0050134LC5220/Jun/27LC
170CON00433ML AMBER GLASS043529LC5531/May/27LCCON00443ML CLEAR GLASS VIAL024667LC5213/Feb/25LC
171CON00443ML CLEAR GLASS VIAL024667LC5213/Feb/25LCCON00443ML CLEAR GLASS VIAL021485LC5108/Jun/24LC
172CON00443ML CLEAR GLASS VIAL021485LC5108/Jun/24LCCON00455ML CLEAR GLASS VIAL036058LC52LC
173CON00455ML CLEAR GLASS VIAL036058LC5228/Jun/26LCCON004610ML GLASS VIAL020454LC5202/Jul/24LC
174CON00455ML CLEAR GLASS VIAL036058LC5228/Jun/26LCCON004610ML GLASS VIAL034210LC5320/Apr/26LC
175CON004610ML GLASS VIAL020454LC5202/Jul/24LCCON004720ML GLASS VIALS7731LC5129/Apr/29LC
176CON004610ML GLASS VIAL034210LC5320/Apr/26LCCON004720ML GLASS VIALS4763LC5107/Oct/30LC
177CON004720ML GLASS VIALS7731LC5129/Apr/29LCCON004825ML GLASS VIALS020141LC5126/Oct/29LC
178CON004720ML GLASS VIALS4763LC5107/Oct/30LCCON004825ML GLASS VIALS029390LC5124/Sep/25LC
179CON004825ML GLASS VIALS020141LC5126/Oct/29LCCON004912 X 75MM TUBES08722008LC241LC
180CON004825ML GLASS VIALS029390LC5124/Sep/25LCCON004912 X 75MM TUBES08922017LC241LC
181CON004912 X 75MM TUBES08722008LC241LCCON004912 X 75MM TUBES09322028LC241LC
182CON004912 X 75MM TUBES08922017LC241LCCON004912 X 75MM TUBES09322028LC241LC
183CON004912 X 75MM TUBES09322028LC241LCCON004912 X 75MM TUBES16522041LC241LC
184CON004912 X 75MM TUBES09322028LC241LCCON004912 X 75MM TUBES16522041LC243LC
185CON004912 X 75MM TUBES16522041LC241LCCON004912 X 75MM TUBES18022062LC241LC
186CON004912 X 75MM TUBES16522041LC243LCCON0052PETRI DISHES19PS3615LC15130/Nov/24LC
187CON004912 X 75MM TUBES18022062LC241LCCON0052PETRI DISHES21PS0399LC15131/Jan/26LC
Static


It should be pulling over row A170:G170 so it lines up on J row but does not seem to be doing it
 

Attachments

  • Capture.PNG
    Capture.PNG
    28.2 KB · Views: 6
Upvote 0

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Re-done it on a new book:

Book1.xlsm
ABCDEFGHIJKLMN
1productdescriptionlot_numberto_bin_numberqtyexpiry_dateproductdescriptionlot_numberto_bin_numberqtyexpiry_date
212004272Cytometer Cleaner64469722LC2624535412004272Cytometer Cleaner64469722LC26245354
312004403ZE Series QC Bead01M-052621LCLAB2824543812004403ZE Series QC Bead01M-052621LCLAB28245438
41351118VIVAFIX 649/6602810132LCLAB2011452491351118VIVAFIX 649/6602810132LCLAB201145249
51450016COUNTING SLIDES64480964LC2651450016COUNTING SLIDES64480964LC265
61610393PRECISION ALL BLUE64456132LCLAB2012452631610393PRECISION ALL BLUE64456132LCLAB201245263
71610393PRECISION ALL BLUE64463382LCLAB2013453261610393PRECISION ALL BLUE64463382LCLAB201345326
81610396UNSTAINED PROTEIN64495841LCLAB2012454801610396UNSTAINED PROTEIN64495841LCLAB201245480
91610610DITHIOTHREITOL (DTT)64434521LCLAB282451371610610DITHIOTHREITOL (DTT)64434521LCLAB28245137
101610737LAEMMLI SAMPLE BUFF64439662LC261451791610737LAEMMLI SAMPLE BUFF64439662LC26145179
111610737LAEMMLI SAMPLE BUFF64476022LC262454121610737LAEMMLI SAMPLE BUFF64476022LC26245412
121610747LAEMMLI SAMPLE BUFF64495266LC171454451610747LAEMMLI SAMPLE BUFF64495266LC17145445
131610772TGS (10x)64486547LC171450661610772TGS (10x)64486547LC17145066
141610772TGS (10x)64486547LC172450661610772TGS (10x)64486547LC17245066
151610782TBS 1% CASEIN BLOCKI64467967LCLAB281464171610782TBS 1% CASEIN BLOCKI64467967LCLAB28146417
161610782TBS 1% CASEIN BLOCKI64473954LCLAB282464411610782TBS 1% CASEIN BLOCKI64473954LCLAB28246441
171704157PVDF TRANSBLOT64465952LCLAB283451491704157PVDF TRANSBLOT64465952LCLAB28345149
181704159MIDI NITROCELLULOSE64455211LCLAB287449521704159MIDI NITROCELLULOSE64455211LCLAB28744952
195678084CRITERION 4-15% TGX64488214BULK00220450695678084CRITERION 4-15% TGX64488214BULK0022045069
205678084CRITERION 4-15% TGX64488214BULK00220450695678084CRITERION 4-15% TGX64488214BULK0022045069
215678084CRITERION 4-15% TGX64493591BULK00220450995678084CRITERION 4-15% TGX64493591BULK0022045099
225678084CRITERION 4-15% TGX64493591BULK0026450995678084CRITERION 4-15% TGX64493591BULK002645099
235678084CRITERION 4-15% TGX64501702BULK0029451395678084CRITERION 4-15% TGX64501702BULK002945139
245678084CRITERION 4-15% TGX64497384BULK00216451185678084CRITERION 4-15% TGX64497384BULK0021645118
255678124ANY KD CRITERION TGX64491863BULK00214450935678124ANY KD CRITERION TGX64491863BULK0021445093
265678124ANY KD CRITERION TGX64491863BULK00229450935678124ANY KD CRITERION TGX64491863BULK0022945093
275678124ANY KD CRITERION TGX64496756BULK00212451145678124ANY KD CRITERION TGX64496756BULK0021245114
285678124ANY KD CRITERION TGX64501740BULK00218451405678124ANY KD CRITERION TGX64501740BULK0021845140
295678124ANY KD CRITERION TGX64501740BULK00234451405678124ANY KD CRITERION TGX64501740BULK0023445140
30CHE0006MYCOALERT ASSAY0001103247LCLAB28345191CHE0006MYCOALERT ASSAY0001103247LCLAB28345191
31CHE0006MYCOALERT ASSAY0001152492LCLAB28445415CHE0006MYCOALERT ASSAY0001152492LCLAB28445415
32CHE0007MYCOALERT + DET KIT200422LCLAB28145071CHE0007MYCOALERT + DET KIT200422LCLAB28145071
33CHE0007MYCOALERT + DET KIT14-JUL-202LCLAB28445121CHE0007MYCOALERT + DET KIT14-JUL-202LCLAB28445121
34CHE0009CONCANAVALIN ASLCC7678LCLAB2011CHE0009CONCANAVALIN ASLCC7678LCLAB2011
35CHE0012IONOMYCIN109M4048VLCLAB281CHE0012IONOMYCIN109M4048VLCLAB281
36CHE0013PMASLBX8889LCLAB2011CHE0013PMASLBX8889LCLAB2011
37CHE0014SHEATH FLUID2210409811LC20145761CHE0014SHEATH FLUID2210409811LC20145761
38CHE0014SHEATH FLUID2218809812LC20545845CHE0014SHEATH FLUID2218809812LC20545845
39CHE0015PHA-PSLCC9870LCLAB281CHE0015PHA-PSLCC9870LCLAB281
40CHE0016FACS CLEAN SOLUTION2135709817LC103CHE0016FACS CLEAN SOLUTION2135709817LC103
41CHE0020HUMAN SERUMSLCF0691LCLAB2012CHE0020HUMAN SERUMSLCF0691LCLAB2012
42CHE0023ACUITY ADVANCEDB365554LCLAB281CHE0023ACUITY ADVANCEDB365554LCLAB281
43CHE0023ACUITY ADVANCEDB372951LCLAB28145446CHE0023ACUITY ADVANCEDB372951LCLAB28145446
44CHE0024CHROMOGEN CONCENTRATB356871LCLAB28145188CHE0024CHROMOGEN CONCENTRATB356871LCLAB28145188
45CHE0025DAB SUBSTRATE BUFFERB355289LCLAB28245271CHE0025DAB SUBSTRATE BUFFERB355289LCLAB28245271
46CHE0026STEMPRO ACCUTASE CEL2M2635ALCLAB201645322CHE0026STEMPRO ACCUTASE CEL2M2635ALCLAB201645322
47CHE0026STEMPRO ACCUTASE CEL2N0238ALCLAB201445350CHE0026STEMPRO ACCUTASE CEL2N0238ALCLAB201445350
48CHE0026STEMPRO ACCUTASE CEL2310199LCLAB2011045350CHE0026STEMPRO ACCUTASE CEL2310199LCLAB2011045350
49CHE0028TC GRADE DMSORNBL1421LC17245443CHE0028TC GRADE DMSORNBL1421LC17245443
50CHE0029NON ESS AMINO ACIDS2511916LCLAB28445291CHE0029NON ESS AMINO ACIDS2511916LCLAB28445291
51CHE0029NON ESS AMINO ACIDS2512133LCLAB284545350CHE0029NON ESS AMINO ACIDS2512133LCLAB284545350
52CHE0030L-GLUTAMINE 200MM2512068FC3045322CHE0030L-GLUTAMINE 200MM2512068FC3045322
53CHE0031D GLUCOSE SOLUTIONRNBL1222LCLAB2810CHE0031D GLUCOSE SOLUTIONRNBL1222LCLAB2810
54CHE0031D GLUCOSE SOLUTIONRNBL1222LCLAB2827CHE0031D GLUCOSE SOLUTIONRNBL1222LCLAB2827
55CHE0033SODIUM PYRUVATE2511572LCLAB284545138CHE0033SODIUM PYRUVATE2511572LCLAB284545138
56CHE0040MYCOPLASMA OFF LIQUI150M22C1LC14COSH345169CHE0040MYCOPLASMA OFF LIQUI150M22C1LC14COSH345169
57CHE0040MYCOPLASMA OFF LIQUI150M22F1LC14COSH445291CHE0040MYCOPLASMA OFF LIQUI150M22F1LC14COSH445291
58CHE0042SHEATH FILTER ASSEMB280421LC102CHE0042SHEATH FILTER ASSEMB280421LC102
59CHE0044LPS0000112732LCLAB281CHE0044LPS0000112732LCLAB281
60CHE0045QUICK COOMASSIE74PT20220+BULK0026CHE0045QUICK COOMASSIE74PT20220+BULK0026
61CHE0045QUICK COOMASSIE77PT22080+BULK0021CHE0045QUICK COOMASSIE77PT22080+BULK0021
62CHE0045QUICK COOMASSIE77PT220801BULK0028CHE0045QUICK COOMASSIE77PT220801BULK0028
63CHE0048A7906-100G BSASLCK4304LCLAB288CHE0048A7906-100G BSASLCK4304LCLAB288
64CHE0048A7906-100G BSASLCM1122LCLAB287CHE0048A7906-100G BSASLCM1122LCLAB287
65CHE0049CS&T RESEARCH BEADS20458LCLAB28145351CHE0049CS&T RESEARCH BEADS20458LCLAB28145351
66CHE0050Hematoxylin QSZJ0527LC32145443CHE0050Hematoxylin QSZJ0527LC32145443
67CHE0051Fetal Bovine Serum2528413RPLCLAB201246568CHE0051Fetal Bovine Serum2528413RPLCLAB201246568
68CON0001CENTRIFUGE16221006LC191CON0001CENTRIFUGE16221006LC191
69CON0001CENTRIFUGE19021003LC193CON0001CENTRIFUGE19021003LC193
70CON0001CENTRIFUGE17122006LC193CON0001CENTRIFUGE17122006LC193
71CON0002SCREWCAP20368LC13147935CON0002SCREWCAP20368LC13147935
72CON0002SCREWCAP22138LC132CON0002SCREWCAP22138LC132
73CON0003SCREWCAP20475LC13247935CON0003SCREWCAP20475LC13247935
74CON0004SCREW CAP21285LC131CON0004SCREW CAP21285LC131
75CON0004SCREW CAP21285LC132CON0004SCREW CAP21285LC132
76CON0006SCREWCAP21375LC131CON0006SCREWCAP21375LC131
77CON0006SCREWCAP21415LC132CON0006SCREWCAP21415LC132
78CON000775CM TC FLASKS10023863LC16245409CON000775CM TC FLASKS10023863LC16245409
79CON000775CM TC FLASKS100026093LC16245789CON000775CM TC FLASKS100026093LC16245789
80CON0008850cm ROLLER BOTTLE1336103LC25445225CON0008850cm ROLLER BOTTLE1336103LC25445225
81CON0009175CM TC FLASKS55519LC21146942CON0009175CM TC FLASKS55519LC21146942
82CON0009175CM TC FLASKS5000397LC21244980CON0009175CM TC FLASKS5000397LC21244980
83CON0010175CM TC FLASKS2101604LC25246475CON0010175CM TC FLASKS2101604LC25246475
84CON0010175CM TC FLASKS2101004LC25446446CON0010175CM TC FLASKS2101004LC25446446
85CON0010175CM TC FLASKS2004007LC25446385CON0010175CM TC FLASKS2004007LC25446385
86CON0010175CM TC FLASKS2004007LC25446385CON0010175CM TC FLASKS2004007LC25446385
87CON0010175CM TC FLASKS2090103LC25446475CON0010175CM TC FLASKS2090103LC25446475
88CON0010175CM TC FLASKS2091013LC25246475CON0010175CM TC FLASKS2091013LC25246475
89CON0010175CM TC FLASKS2096003LC25246475CON0010175CM TC FLASKS2096003LC25246475
90CON0011SMALL TISSUE CULTURE10024905-+LC24245695CON0011SMALL TISSUE CULTURE10024905-+LC24245695
91CON0011SMALL TISSUE CULTURE100026353+LC24245803CON0011SMALL TISSUE CULTURE100026353+LC24245803
92CON0012MEDIUM TC FLASKS100024905+LC16145704CON0012MEDIUM TC FLASKS100024905+LC16145704
93CON0012MEDIUM TC FLASKS100025382+LC16245740CON0012MEDIUM TC FLASKS100025382+LC16245740
94CON0013500ML PP CENTRIFUGE22522020LC20245882CON0013500ML PP CENTRIFUGE22522020LC20245882
95CON0013500ML PP CENTRIFUGE20522017LC20245862CON0013500ML PP CENTRIFUGE20522017LC20245862
96CON001460ML NALGENE BOTTLES1318451LC284CON001460ML NALGENE BOTTLES1318451LC284
97CON0015125ML NALGENE BOTTLE1321408LC301CON0015125ML NALGENE BOTTLE1321408LC301
98CON0015125ML NALGENE BOTTLE1321408LC304CON0015125ML NALGENE BOTTLE1321408LC304
99CON001650ML CENTRIFUGE TUBE27021035LC34246291CON001650ML CENTRIFUGE TUBE27021035LC34246291
100CON001650ML CENTRIFUGE TUBE28421094LC34246307CON001650ML CENTRIFUGE TUBE28421094LC34246307
101CON0017500ML NALGENE BOTTLE1219853LC31146940CON0017500ML NALGENE BOTTLE1219853LC31146940
102CON0017500ML NALGENE BOTTLE1225550LC31147384CON0017500ML NALGENE BOTTLE1225550LC31147384
103CON0018250ML NALGENE BOTTLE1253162LC31247299CON0018250ML NALGENE BOTTLE1253162LC31247299
104CON001915ML CENTRIFUGE TUBE27521032LC33246296CON001915ML CENTRIFUGE TUBE27521032LC33246296
105CON001915ML CENTRIFUGE TUBE30521044LC33146325CON001915ML CENTRIFUGE TUBE30521044LC33146325
106CON001915ML CENTRIFUGE TUBE30521044LC33146326CON001915ML CENTRIFUGE TUBE30521044LC33146326
107CON001915ML CENTRIFUGE TUBE14622046LC33146532CON001915ML CENTRIFUGE TUBE14622046LC33146532
108CON001915ML CENTRIFUGE TUBE00322040LC33146447CON001915ML CENTRIFUGE TUBE00322040LC33146447
109CON001915ML CENTRIFUGE TUBE00322040LC33346390CON001915ML CENTRIFUGE TUBE00322040LC33346390
110CON001915ML CENTRIFUGE TUBE00322040LC33146390CON001915ML CENTRIFUGE TUBE00322040LC33146390
111CON00201 LITRE NALGEN BOTTL1399905LC32247328CON00201 LITRE NALGEN BOTTL1399905LC32247328
112CON00201 LITRE NALGEN BOTTL1325575LC322CON00201 LITRE NALGEN BOTTL1325575LC322
113CON00212ML CRYOVIALS INTERN170115LC11146234CON00212ML CRYOVIALS INTERN170115LC11146234
114CON00212ML CRYOVIALS INTERN173088LC11246538CON00212ML CRYOVIALS INTERN173088LC11246538
115CON00221.5ML MICROCENTRIFUG22102079LC142CON00221.5ML MICROCENTRIFUG22102079LC142
116CON00221.5ML MICROCENTRIFUG22102079LC145CON00221.5ML MICROCENTRIFUG22102079LC145
117CON0023MICROCENTRIFUGE TUBE20P1023102LC14447695CON0023MICROCENTRIFUGE TUBE20P1023102LC14447695
118CON0023MICROCENTRIFUGE TUBE20P1032102LC144CON0023MICROCENTRIFUGE TUBE20P1032102LC144
119CON002410ml Tube801188LC341CON002410ml Tube801188LC341
120CON002410ml Tube821341LC342CON002410ml Tube821341LC342
121CON002410ml Tube822970LC344CON002410ml Tube822970LC344
122CON002530ML NALGENE BOTTLES1270094LC293CON002530ML NALGENE BOTTLES1270094LC293
123CON002530ML NALGENE BOTTLES120094LC292CON002530ML NALGENE BOTTLES120094LC292
124CON00280.5ML NATURAL VIALS1352492LC332CON00280.5ML NATURAL VIALS1352492LC332
125CON00280.5ML NATURAL VIALS1352492LC334CON00280.5ML NATURAL VIALS1352492LC334
126CON00280.5ML NATURAL VIALS1352492LC334CON00280.5ML NATURAL VIALS1352492LC334
127CON00280.5ML NATURAL VIALS1352492LC334CON00280.5ML NATURAL VIALS1352492LC334
128CON00280.5ML NATURAL VIALS1352492LC334CON00280.5ML NATURAL VIALS1352492LC334
129CON00280.5ML NATURAL VIALS1352492LC334CON00280.5ML NATURAL VIALS1352492LC334
130CON00292ML NATURAL VIALS1321354LC11CON00292ML NATURAL VIALS1321354LC11
131CON00292ML NATURAL VIALS1321935LC13CON00292ML NATURAL VIALS1321935LC13
132CON00292ML NATURAL VIALS1321935LC19CON00292ML NATURAL VIALS1321935LC19
133CON00300.5ML AMBER VIALS1276403LC12CON00300.5ML AMBER VIALS1276403LC12
134CON00300.5ML AMBER VIALS1272844LC13CON00300.5ML AMBER VIALS1272844LC13
135CON00300.5ML AMBER VIALS1327524LC11CON00300.5ML AMBER VIALS1327524LC11
136CON00300.5ML AMBER VIALS1343242LC13CON00300.5ML AMBER VIALS1343242LC13
137CON00300.5ML AMBER VIALS1332812LC15CON00300.5ML AMBER VIALS1332812LC15
138CON00312ML AMBER VIALS1349099LC11CON00312ML AMBER VIALS1349099LC11
139CON00312ML AMBER VIALS1349099LC14CON00312ML AMBER VIALS1349099LC14
140CON0032NATURAL CLOSURE1342762LC31CON0032NATURAL CLOSURE1342762LC31
141CON0032NATURAL CLOSURE1342762LC33CON0032NATURAL CLOSURE1342762LC33
142CON0032NATURAL CLOSURE1349473LC32CON0032NATURAL CLOSURE1349473LC32
143CON0032NATURAL CLOSURE1349473LC35CON0032NATURAL CLOSURE1349473LC35
144CON0032NATURAL CLOSURE1349473LC34CON0032NATURAL CLOSURE1349473LC34
145CON0032NATURAL CLOSURE1349473LC31CON0032NATURAL CLOSURE1349473LC31
146CON0032NATURAL CLOSURE1349473LC35CON0032NATURAL CLOSURE1349473LC35
147CON0032NATURAL CLOSURE1360216LC35CON0032NATURAL CLOSURE1360216LC35
148CON0036AMBER CLOSURE1311963LC31CON0036AMBER CLOSURE1311963LC31
149CON0036AMBER CLOSURE1311963LC32CON0036AMBER CLOSURE1311963LC32
150CON0036AMBER CLOSURE1311963LC32CON0036AMBER CLOSURE1311963LC32
151CON0036AMBER CLOSURE1311963LC32CON0036AMBER CLOSURE1311963LC32
152CON0036AMBER CLOSURE1354026LC31CON0036AMBER CLOSURE1354026LC31
153CON0036AMBER CLOSURE1354026LC31CON0036AMBER CLOSURE1354026LC31
154CON0036AMBER CLOSURE1354026LC31CON0036AMBER CLOSURE1354026LC31
155CON0036AMBER CLOSURE1354026LC32CON0036AMBER CLOSURE1354026LC32
156CON003715.5MM WADLESS CAPS031123LC27445822CON003715.5MM WADLESS CAPS031123LC27445822
157CON003715.5MM WADLESS CAPS033612LC275CON003715.5MM WADLESS CAPS033612LC275
158CON003715.5MM WADLESS CAPS040660LC27146401CON003715.5MM WADLESS CAPS040660LC27146401
159CON003822MM WADLESS CAPS011133LC27146936CON003822MM WADLESS CAPS011133LC27146936
160CON003822MM WADLESS CAPS033270LC271CON003822MM WADLESS CAPS033270LC271
161CON003822MM WADLESS CAPS038900LC272CON003822MM WADLESS CAPS038900LC272
162CON003915MM RUBBER STOPPERS036061LC281CON003915MM RUBBER STOPPERS036061LC281
163CON003915MM RUBBER STOPPERS043329LC28346527CON003915MM RUBBER STOPPERS043329LC28346527
164CON004022MM RUBBER STOPPERS14194LC28146703CON004022MM RUBBER STOPPERS14194LC28146703
165CON004022MM RUBBER STOPPERS026471LC28145783CON004022MM RUBBER STOPPERS026471LC28145783
166CON0041CLEAR GLASS VIALS18183LC29147931CON0041CLEAR GLASS VIALS18183LC29147931
167CON0041CLEAR GLASS VIALS18183LC291CON0041CLEAR GLASS VIALS18183LC291
168CON004250ML GLASS VIAL10538LC294CON004250ML GLASS VIAL10538LC294
169CON00433ML AMBER GLASSP0050134LC5246558CON00433ML AMBER GLASSP0050134LC5246558
170CON00433ML AMBER GLASS043529LC5546538CON00433ML AMBER GLASSP0050134LC5246558
171CON00443ML CLEAR GLASS VIAL024667LC5245701CON00443ML CLEAR GLASS VIAL024667LC5245701
172CON00443ML CLEAR GLASS VIAL021485LC5145451CON00443ML CLEAR GLASS VIAL021485LC5145451
173CON00455ML CLEAR GLASS VIAL036058LC5246201CON00455ML CLEAR GLASS VIAL36058LC5246201
174CON00455ML CLEAR GLASS VIAL036058LC5246201CON00455ML CLEAR GLASS VIAL036058LC52
175CON004610ML GLASS VIAL020454LC5245475CON004610ML GLASS VIAL020454LC5245475
176CON004610ML GLASS VIAL034210LC5346132CON004610ML GLASS VIAL034210LC5346132
177CON004720ML GLASS VIALS7731LC5147237CON004720ML GLASS VIALS7731LC5147237
178CON004720ML GLASS VIALS4763LC5147763CON004720ML GLASS VIALS4763LC5147763
179CON004825ML GLASS VIALS020141LC5147417CON004825ML GLASS VIALS020141LC5147417
180CON004825ML GLASS VIALS029390LC5145924CON004825ML GLASS VIALS029390LC5145924
Sheet1



VBA Code:
Sub Compare()
    Dim Ary As Variant
    Dim i As Long, j As Long, zCol As Long
    Dim shtData As Worksheet
    Dim lrRECP1 As Long, lrComp As Long
    Dim rngRECP1 As Range, rngComp As Range
    
    Set shtData = ActiveSheet
    
    With shtData
        lrRECP1 = .Range("A" & Rows.Count).End(xlUp).Row
        Set rngRECP1 = .Range(.Cells(1, "A"), .Cells(lrRECP1, "F"))
        lrComp = .Range("I" & Rows.Count).End(xlUp).Row
        Set rngComp = .Range(.Cells(1, "I"), .Cells(lrComp, "N"))
    End With
    
    Ary = rngRECP1.Value2
    With rngComp
        j = lrComp
        For i = UBound(Ary) To 2 Step -1
            If .Cells(j, 1).Value = Ary(i, 1) Then
                j = j - 1
            Else
                .Rows(j + 1).Insert Shift:=xlDown
                For zCol = 1 To Columns("F").Column
                    .Cells(j + 1, zCol).Value = Ary(i, zCol)
                Next zCol
                .Rows(j + 1).Interior.Color = vbYellow
            End If
        Next i
    End With
End Sub

same thing
 
Upvote 0
The result on the image you’ve posted looks expected. You are enumerating cells from bottom to top, so row 170 on the left side is equal to row 169 on the right side.

There are a few points I would like to note:

  • Both ranges contain duplicate keys (value of the first column)
  • Ranges must be sorted by first column (key)
If ranges are not sorted – this algorithm will not work.

Duplicate records also have effect on the output. If you enumerate cells from top to bottom and from bottom to top, there will be difference results. Because in this loop you are copying first row, that doesn’t have matching row in the corresponding range.

Worksheets you’ve posted have a bit different structure. So, I’ve recreated this code in the following way:

  • It doesn’t depend on the hardcoded ranges
  • 2 variants on the Compare function – go by cells from top to bottom and from bottom to top (like in your example)

Also, it highlights records on the right side, that are not present in the left range. This is for information only. You can remove this line if it is not needed.

I've explained code in comments in the first function, second one is very similar, so I've missed the explanations.

If you will use CompareTopToBottom macro, it will give you different result for the rows 170-169

Hope this helps.

VBA Code:
Option Explicit

Public Sub CompareBottomToTop()
    ' with this line code will work faster
    Application.ScreenUpdating = False
    
    ' two ranges with data
    ' Left one contains source data
    ' Right one receives missed records
    Dim LeftRange As Range
    Dim RightRange As Range

    ' get the left range
    Range("A1").Select
    Range(Selection, Selection.End(xlToRight)).Select
    Set LeftRange = Range(Selection, Selection.End(xlDown))
    
    ' get the right range
    Range("A1").Select
    ' skip left range
    Selection.End(xlToRight).Select
    ' one step to select leftmost cell in the right range
    Selection.End(xlToRight).Select
    ' get the range
    Range(Selection, Selection.End(xlToRight)).Select
    Set RightRange = Range(Selection, Selection.End(xlDown))
    
    ' rows to navigate through left and right ranges
    Dim LeftRow As Long
    Dim RightRow As Long
    
    ' we start from the last row
    LeftRow = LeftRange.Rows.Count
    RightRow = RightRange.Rows.Count
    
    ' cell to be copied
    Dim Cell As Range
    
    ' main loop
    While LeftRow > 0 And RightRow > 0
        ' if left cell is less than right one - right row is not present on the left side
        If LeftRange.Cells(LeftRow, 1) < RightRange.Cells(RightRow, 1) Then
            ' highlight it and skip
            RightRange.Rows(RightRow).Interior.Color = vbGreen
            RightRow = RightRow - 1
        ElseIf LeftRange.Cells(LeftRow, 1) = RightRange.Cells(RightRow, 1) Then
            ' both rows have same key - skip
            LeftRow = LeftRow - 1
            RightRow = RightRow - 1
        Else
            ' left row is not present on the right side
            With RightRange
            
                ' insert empty space
                .Rows(RightRow + 1).Insert Shift:=xlDown
                
                ' go through every cell in the left row and copy it to the right
                For Each Cell In LeftRange.Rows(LeftRow).Cells
                    .Cells(RightRow + 1, Cell.Column - LeftRange.Column + 1) = Cell
                Next
                
                ' highlight with color
                .Rows(RightRow + 1).Interior.Color = vbYellow
                
            End With
            
            ' skip row that we've copied
            LeftRow = LeftRow - 1
        End If
    Wend
    
    Application.ScreenUpdating = True
End Sub

Public Sub CompareTopToBottom()

    Application.ScreenUpdating = False
    
    Dim LeftRange As Range
    Dim RightRange As Range

    Range("A1").Select
    Range(Selection, Selection.End(xlToRight)).Select
    Set LeftRange = Range(Selection, Selection.End(xlDown))
    
    Range("A1").Select
    Selection.End(xlToRight).Select
    Selection.End(xlToRight).Select
    Range(Selection, Selection.End(xlToRight)).Select
    Set RightRange = Range(Selection, Selection.End(xlDown))
    
    Dim LeftRow As Long
    Dim RightRow As Long
    
    LeftRow = 1
    RightRow = 1
    
    Dim Cell As Range
    
    While LeftRow <= LeftRange.Rows.Count And RightRow <= RightRange.Rows.Count
        If LeftRange.Cells(LeftRow, 1) > RightRange.Cells(RightRow, 1) Then
            RightRange.Rows(RightRow).Interior.Color = vbGreen
            RightRow = RightRow + 1
        ElseIf LeftRange.Cells(LeftRow, 1) = RightRange.Cells(RightRow, 1) Then
            LeftRow = LeftRow + 1
            RightRow = RightRow + 1
        Else
            With RightRange
            
                .Rows(RightRow).Insert Shift:=xlDown
                
                For Each Cell In LeftRange.Rows(LeftRow).Cells
                    .Cells(RightRow, Cell.Column - LeftRange.Column + 1) = Cell
                Next
                
                .Rows(RightRow).Interior.Color = vbYellow
                
            End With
            
            LeftRow = LeftRow + 1
            RightRow = RightRow + 1
        End If
    Wend
    
    ' this this case we need to copy rows, that may left in the left range
    While LeftRow <= LeftRange.Rows.Count

        With RightRange
        
            .Rows(RightRow).Insert Shift:=xlDown
            
            For Each Cell In LeftRange.Rows(LeftRow).Cells
                .Cells(RightRow, Cell.Column - LeftRange.Column + 1) = Cell
            Next
            
            .Rows(RightRow).Interior.Color = vbYellow
            
        End With
        
        LeftRow = LeftRow + 1
        RightRow = RightRow + 1

    Wend
    
    Application.ScreenUpdating = True
End Sub
 
Upvote 0
Thanks for the explanation @SpreadsheetTools works really well and in tables too!
I added a macro to sort both first columns and then run it :)
 
Upvote 0

Forum statistics

Threads
1,223,238
Messages
6,170,939
Members
452,368
Latest member
jayp2104

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