put the values multiple columns into adjacent value based on match another column

leap out

Active Member
Joined
Dec 4, 2020
Messages
271
Office Version
  1. 2016
  2. 2010
Hi Guys
I hope finding way to brings data from sheet report . so should match column B:D for sheet REPORT with column B for sheet STOCK , then should put the data into E:I for each adjacent cell into column B after match column B:D for sheet REPORT and if there are items are existed in sheet REPORT but are not existed in column B for sheet STOCK , then should be added into E: I as shows in result . as to the values in column I should brings from the last column NET . the last column NET (M) is not the last column. I will insert new columns then will change the column NET in location (this means the column M is not range end when brings the values if I insert new column after it ) .

sheet REPORT
(5).xlsx
ABCDEFGHIJKLM
1CLASSIFICATIONGOODSMARKMANFACTUREBUYINGSELLINGNETBUYINGSELLINGNETBUYINGSELLINGNET
2OIL-AS2 MLO-1 10W40 208L TT/LCASSU20020020040360-2358
310W40 208LENIIT30030040020680400201060
45W30 208LQ8EU120120602016060-220
510W40 208LQ8EU100100100-100-
6TOTAL7200720660801300--1638
7OIL-AS210W40 12x1LQ8EU12312310010213-10203
810W40 12x1LCASSU3030600562560051220
910W40 12x1LENIIT120120125245125-370
10OL-115W40 12x1LCASSU**200131131-131-
11TOTAL27302739561512147251461793
12MS-OIL15W30 12x1LQ8EU200200100300100-400
1310W40 4x4LQ8EU300300300--300
14OIL/M 10W40 4x4LCAS TRMSU N3-90230230230--230
1510W40 4x4L MNH/80-TENIIT L66RT123123125125123125125123
165W40 4x4LQ8EU456456456--456
175W40 4x4LCASSU234234234--234
185W40 4x4LENIIT230230202023020-250
1920W50 4x4LQ8EU1231231013310-143
2020W50 4x4LCASSU56056012548-12536
2120W50 4x4LENIIT120120120--120
225W30 4x4LQ8EU303030--30
23TOTAL26060260625515727042551372822
REPORT
Cell Formulas
RangeFormula
M6,E11:M11,E6:J6E6=SUM(E2:E5)
G12:G22,G7:G10,G2:G5G2=E2-F2
M12:M22,M7:M10,M2:M5,J12:J22,J7:J10,J2:J5J2=G2+H2-I2
E23:M23E23=SUM(E12:E22)


sheet STOCK
(5).xlsx
ABCDEFGHI
1ITEMGOODSQTYITEMGOODSMARKMANFACTURENET
2110W40 12x1L Q8 EU200
3210W40 12x1L CAS SU120
4310W40 12x1L ENI IT300
54OL-115W40 12x1L CAS SU**2240
65 MLO-1 10W40 208L TT/L CAS SU150
7610W40 208L ENI IT160
875W30 208L Q8 EU200
98OIL/M 10W40 4x4L CAS TRM SU N3-90120
10
11
12
13
14
15
16
17
18
19
20
STOCK


after

(5).xlsx
ABCDEFGHI
1ITEMGOODSQTYITEMGOODSMARKMANFACTURENET
2110W40 12x1L Q8 EU200110W40 12x1LQ8EU203
3210W40 12x1L CAS SU120210W40 12x1LCASSU1220
4310W40 12x1L ENI IT300310W40 12x1LENIIT370
54OL-115W40 12x1L CAS SU**22404OL-115W40 12x1LCASSU**2-
65 MLO-1 10W40 208L TT/L CAS SU1505 MLO-1 10W40 208L TT/LCASSU358
7610W40 208L ENI IT160610W40 208LENIIT1060
875W30 208L Q8 EU20075W30 208LQ8EU220
98OIL/M 10W40 4x4L CAS TRM SU N3-901208OIL/M 10W40 4x4LCAS TRMSU N3-90230
10910W40 208LQ8EU-
11105W30 12x1LQ8EU400
121110W40 4x4LQ8EU300
131210W40 4x4L MNH/80-TENIIT L66RT123
14135W40 4x4LQ8EU456
15145W40 4x4LCASSU234
16155W40 4x4LENIIT250
171620W50 4x4LQ8EU143
181720W50 4x4LCASSU536
191820W50 4x4LENIIT120
20195W30 4x4LQ8EU30
STOCK
 
great ! this is exactly what I want. but I have question why the code seems slow. it gives running speed 0.940 I thinks this much time with comparison small data if you can make it 0.02 or 0.03 will be great and I truly appreciate for that
Try to test again with your actual data. Insert more dummy data.
How long does it take ?
If not, try to send file via google drive.
I had tried my best to use variable array to reduce the code speed.
Hope someone can help you out.
 
Upvote 0

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
I no know what happens . actually after many tries it gives 0.140 . this is very acceptable

but I have question if I have less than 10000 rows . for instance 1000 rows code runs loop throught 10000 rows even they are empty rows .

if so I think this is the reason make the code is slow if the data are small I think the loop should be throught the rows contain data without pass the others empty rows . what do you think to avoid this problem ?
 
Upvote 0
With this:
lr = .Cells(Rows.count, "B").End(xlUp).Row
code works for range from first row to last row of column B only.
 
Upvote 0

Forum statistics

Threads
1,215,274
Messages
6,123,993
Members
449,137
Latest member
abdahsankhan

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