insert row for new items before TOTAL row based on matching between two sheet

Mussa

Board Regular
Joined
Jul 12, 2021
Messages
240
Office Version
  1. 2019
  2. 2010
hi experts
I have two sheets DATA and RESULT . the result should be in sheet RESULT . so what I want match data between two sheets in COL B,C ,D for each item in COL A the values should be in last columns IMPORT, EXPORT because every time I insert theses columns
as you see each item in COL A contains data based on starts from first cell in COL A and end to last empty cell before start new item for both sheets to make easy match data .
when if new data are existed in sheet data but not existed in sheet before then add to before TOTAL row as highlighted by red and if there are existed into two sheets then should pull the values and put in last columns IMPORT , EXPORT as highlighted by blue after match the data for each item in COLA . by the way my real data are about 3000 rows and will increase continuously in sheet DATA . may be asking yourself about the values in col E,F,G . it depend on sheet data . every time change the values and add a new data then should show the values next to empty columns IMPORT, EXPORT
note: when insert new row should not affect for the borders and formulas . I put the result in sheet result

sheet data
ttt.xlsm
ABCDEF
1DEL NOBATCH NO TTLTT1IMPORTEXPORT
2CC-1CC-1SS-1TRU1210
3CC-1SS-1LTR125
4CC-2SS-2FG55
5CC-2CC-1SS-1TRR105
6CC-1SS-1LTR2010
7CD-1CS-1LL-1RRL155
8CS-2LL-2TTY1010
9CS-3LL-3MMW2010
10CS-4LL-4NNW1010
11CCLCC-2SS-2LTR215
12CCMCC-3SS-3LTR225
DATA



sheet result before
ttt.xlsm
ABCDEFGHIJKLM
1DEL NOBATCH NO TTLTT1IMPORTEXPORTBALANCEIMPORTEXPORTBALANCEIMPORTEXPORTBALANCE
2CC-1CC-1SS-1TRU1201011000
3CC-1SS-1LTR105500
4TOTAL13015115000000
5CC-2CC-1SS-1TRR1551000
6CC-1SS-1LTR101000
7TOTAL25520000000
8CD-1CS-1LL-1RRL101000
9CS-2LL-2TTY5500
10CS-3LL-3MMW5500
11TOTAL20020000000
12CCLCC-2SS-2LTR101000
13TOTAL10035000000
14CCMCC-3SS-3LTR10222223
15TOTAL1002200220023
RESULT
Cell Formulas
RangeFormula
K15:L15,H15:I15,K13:L13,H13:I13,E7:M7,E4:M4E4=SUM(E2:E3)
F13:G13,M11,J11,E11:G11E11=SUM(E8:E10)
M15,J15,E15:G15,M13,J13,E13,K11:L11,H11:I11H11=SUM(H10:H10)
M12,M8:M10,M5:M6,M2:M3,J12,J8:J10,J5:J6,J2:J3,G12,G8:G10,G5:G6,G2:G3G2=E2-F2



sheet result after
ttt.xlsm
ABCDEFGHIJ
1DEL NOBATCH NO TTLTT1IMPORTEXPORTBALANCEIMPORTEXPORTBALANCE
2CC-1CC-1SS-1TRU1201011012102
3CC-1SS-1LTR10551257
4CC-2SS-2FG055
5TOTAL13015115291514
6CC-2CC-1SS-1TRR155101055
7CC-1SS-1LTR1010201010
8TOTAL2552015
9CD-1CS-1LL-1RRL101015510
10CS-2LL-2TTY5510100
11CS-3LL-3MMW55201010
12CS-4LL-4NNW010100
13TOTAL20020553520
14CCLCC-2SS-2LTR101021516
15TOTAL1001016
16CCMCC-3SS-3LTR102222522
17TOTAL1002222
AFTER
Cell Formulas
RangeFormula
E5:J5E5=SUM(E2:E4)
J8,E8:G8E8=SUM(E6:E7)
E13:J13E13=SUM(E9:E12)
J14,J9:J12,J6:J7,J2:J4,G14,G9:G12,G6:G7,G2:G4G2=E2-F2
J17,E17:G17,J15,E15:G15E15=SUM(E14:E14)
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.

Forum statistics

Threads
1,214,832
Messages
6,121,843
Members
449,051
Latest member
excelquestion515

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