Need a function to add values whenever there are same truck numbers

DavidCruz07

New Member
Joined
Mar 1, 2017
Messages
4
(A) (B) (C) (D) (E) (F) (G) (H) (I) (J) (K)
Truck Small Big Total Result Truck Small Big Total Result
877336 146 3 149 5.7 877336 615 67 682 26.2
843501 1346 94 1440 55.4 311944 400 100 500 35.7
345201 390 7 397 28.4 839133 1331 125 1456 56.0
311944 500 50 550 39.3 307612 582 82 664 47.4


First row(A)= Truck number

Fourth Row(D)= Small + Big
Excel function I currently have
=SUM(B2+C2)

Fifth Row(E)= Fourth Row/14 when Truck number starts with "3*****"
Excel function I currently have
=IF(A1>"800000",D2/26,D2/14)

Fifth Row(E)=Fourth Row/26 when Truck number starts with "8*****"
Excel function I currently have
=IF(A1>"800000",D2/26,D2/14)

Red Text= When the same Truck number appears in both Table 1 (A:E) and Table 2 (G:K)

My question is, is there a formula I can use to add the Fourth row (D) data together from Table 1 and Table 2 and have it divided accordingly by 14 or 26 when the truck numbers appear the same under Table 1 and Table 2

This is what I want the function to do, Since table 1 and table 2 both have the truck number"877336" I want excel to add the values from both fourth row together (D2+J2), so 149+682= 831 and then since the truck number starts with "8*****" have it divided by 26 and display it on the fifth row(E and K) for both tables. so 831/26= 32. So the fifth row (E and K) would display 32 in both Table 1 and Table 2 for Truck "877336"

Similar as to truck number 311944 where it is under both table 1 and table 2. the function would add 550+500= 1050. and divide it by 14 since it starts with "3*****" and display 75 under Results (E and K)

Again I ONLY want the numbers to add when the truck numbers are the same, if not the same truck number then just proceed with the regular formula where it divides it by 14 or 26 depending on the truck number

ALSO Whenever there is a truck number that is the same in both table 1 and table 2 doesn't necessary mean they will both appear in the same column. for example truck number 877336 is position in
A2 in table 1 and G2 in table 2, which IS in same column. However this is not always the case, truck number 311944 is position in A5 and G3, which is in a DIFFERENT column. So I need the function to be able to work with that too. So for example position A4(truck number:311944) would search through G2:G5 for a the same truck number

I've been stuck on trying to get a function to work like this. If you need anymore details to solve my excel problem please let me know
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
Re: EXCEL PROBLEM Need a function to add values whenever there are same truck numbers

[TABLE="width: 500"]
<tbody>[TR]
[TD][/TD]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[TD]D[/TD]
[TD]E[/TD]
[TD]F[/TD]
[TD]G[/TD]
[TD]H[/TD]
[TD]I[/TD]
[TD]J[/TD]
[TD]K[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]Truck[/TD]
[TD]Small[/TD]
[TD]Big[/TD]
[TD]Total[/TD]
[TD]Result[/TD]
[TD][/TD]
[TD]Truck[/TD]
[TD]Small[/TD]
[TD]Big[/TD]
[TD]Total [/TD]
[TD]Result[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]877336[/TD]
[TD]146[/TD]
[TD]3[/TD]
[TD]149[/TD]
[TD]5.7[/TD]
[TD][/TD]
[TD]877336[/TD]
[TD]615[/TD]
[TD]67[/TD]
[TD]682[/TD]
[TD]26.2[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]843501[/TD]
[TD]1346[/TD]
[TD]94[/TD]
[TD]1440[/TD]
[TD]55.4[/TD]
[TD][/TD]
[TD]311944[/TD]
[TD]400[/TD]
[TD]100[/TD]
[TD]500[/TD]
[TD]35.7[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]345201[/TD]
[TD]390[/TD]
[TD]7[/TD]
[TD]397[/TD]
[TD]28.4[/TD]
[TD][/TD]
[TD]839133[/TD]
[TD]1331[/TD]
[TD]125[/TD]
[TD]1456[/TD]
[TD]56[/TD]
[/TR]
[TR]
[TD]5[/TD]
[TD]311944[/TD]
[TD]500[/TD]
[TD]50[/TD]
[TD]550[/TD]
[TD]39.3[/TD]
[TD][/TD]
[TD]307612[/TD]
[TD]582[/TD]
[TD]82[/TD]
[TD]664[/TD]
[TD]47.4[/TD]
[/TR]
</tbody>[/TABLE]
 
Upvote 0
Re: EXCEL PROBLEM Need a function to add values whenever there are same truck numbers

Hi, welcome to the forum!

Is this what you mean about getting the total from the 2nd table?


Excel 2013
ABCDEFGHIJKL
1TruckSmallBigTotalResultNewTruckSmallBigTotalResult
287733614631495.78318773366156768226.2
38435011346941440102.9144031194440010050035.7
4345201390739728.43978391331331125145656
53119445005055039.310503076125828266447.4
Database
Cell Formulas
RangeFormula
F2=D2+SUMIFS(K:K,H:H,A2)
 
Upvote 0
Re: EXCEL PROBLEM Need a function to add values whenever there are same truck numbers

Hi, welcome to the forum!

Is this what you mean about getting the total from the 2nd table?

Excel 2013
ABCDEFGHIJKL
TruckSmallBigTotalResultNewTruckSmallBigTotalResult

<colgroup><col><col><col><col><col><col><col><col><col><col><col><col><col></colgroup><thead>
</thead><tbody>
[TD="align: center"]1[/TD]

[TD="align: right"][/TD]

[TD="align: center"]2[/TD]
[TD="align: right"]877336[/TD]
[TD="align: right"]146[/TD]
[TD="align: right"]3[/TD]
[TD="align: right"]149[/TD]
[TD="align: right"]5.7[/TD]
[TD="bgcolor: #FFFF00, align: right"]831[/TD]
[TD="align: right"][/TD]
[TD="align: right"]877336[/TD]
[TD="align: right"]615[/TD]
[TD="align: right"]67[/TD]
[TD="align: right"]682[/TD]
[TD="align: right"]26.2[/TD]

[TD="align: center"]3[/TD]
[TD="align: right"]843501[/TD]
[TD="align: right"]1346[/TD]
[TD="align: right"]94[/TD]
[TD="align: right"]1440[/TD]
[TD="align: right"]102.9[/TD]
[TD="align: right"]1440[/TD]
[TD="align: right"][/TD]
[TD="align: right"]311944[/TD]
[TD="align: right"]400[/TD]
[TD="align: right"]100[/TD]
[TD="align: right"]500[/TD]
[TD="align: right"]35.7[/TD]

[TD="align: center"]4[/TD]
[TD="align: right"]345201[/TD]
[TD="align: right"]390[/TD]
[TD="align: right"]7[/TD]
[TD="align: right"]397[/TD]
[TD="align: right"]28.4[/TD]
[TD="align: right"]397[/TD]
[TD="align: right"][/TD]
[TD="align: right"]839133[/TD]
[TD="align: right"]1331[/TD]
[TD="align: right"]125[/TD]
[TD="align: right"]1456[/TD]
[TD="align: right"]56[/TD]

[TD="align: center"]5[/TD]
[TD="align: right"]311944[/TD]
[TD="align: right"]500[/TD]
[TD="align: right"]50[/TD]
[TD="align: right"]550[/TD]
[TD="align: right"]39.3[/TD]
[TD="align: right"]1050[/TD]
[TD="align: right"][/TD]
[TD="align: right"]307612[/TD]
[TD="align: right"]582[/TD]
[TD="align: right"]82[/TD]
[TD="align: right"]664[/TD]
[TD="align: right"]47.4[/TD]

</tbody>
Database

[TABLE="width: 85%"]
<tbody>[TR]
[TD]Worksheet Formulas[TABLE="width: 100%"]
<thead>[TR="bgcolor: #DAE7F5"]
[TH="width: 10"]Cell[/TH]
[TH="align: left"]Formula[/TH]
[/TR]
</thead><tbody>[TR]
[TH="width: 10, bgcolor: #DAE7F5"]F2[/TH]
[TD="align: left"]=D2+SUMIFS(K:K,H:H,A2)[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
</tbody>[/TABLE]

Not quite, I want the function to be in the Result row. Not in a new row like the one you added as "New"
But yes that would be correct how it added the Totals. But after that it would need to be divided by 14 or 26 depending on what the truck number starts with.

For example the after the function added 149 + 682 = 831 it would be divided by 26. 831/26 displaying "32". Its divided by 26 because the truck number began with "8*****"

Same for truck number 311944, 500+550= 1050 then divided by 14 since the truck number began with "3*****" so 1050/14 = 75

So the end result of the table would display the following
[TABLE="width: 500"]
<tbody>[TR]
[TD][/TD]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[TD]D[/TD]
[TD]E[/TD]
[TD]F[/TD]
[TD]G[/TD]
[TD]H[/TD]
[TD]I[/TD]
[TD]J[/TD]
[TD]K[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]Truck[/TD]
[TD]Small[/TD]
[TD]Big[/TD]
[TD]Total[/TD]
[TD]Result[/TD]
[TD][/TD]
[TD]Truck[/TD]
[TD]Small[/TD]
[TD]Big[/TD]
[TD]Total[/TD]
[TD]Result[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]877336[/TD]
[TD]146[/TD]
[TD]3[/TD]
[TD]149[/TD]
[TD]32[/TD]
[TD][/TD]
[TD]877336[/TD]
[TD]615[/TD]
[TD]67[/TD]
[TD]682[/TD]
[TD]32[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]843501[/TD]
[TD]1346[/TD]
[TD]94[/TD]
[TD]1440[/TD]
[TD]55.4[/TD]
[TD][/TD]
[TD]311944[/TD]
[TD]400[/TD]
[TD]100[/TD]
[TD]500[/TD]
[TD]75[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]345201[/TD]
[TD]390[/TD]
[TD]7[/TD]
[TD]397[/TD]
[TD]28.4[/TD]
[TD][/TD]
[TD]839133[/TD]
[TD]1331[/TD]
[TD]125[/TD]
[TD]1456[/TD]
[TD]56[/TD]
[/TR]
[TR]
[TD]5[/TD]
[TD]311944[/TD]
[TD]500[/TD]
[TD]50[/TD]
[TD]550[/TD]
[TD]75[/TD]
[TD][/TD]
[TD]307612[/TD]
[TD]582[/TD]
[TD]82[/TD]
[TD]664[/TD]
[TD]47.4[/TD]
[/TR]
</tbody>[/TABLE]

As you can see it should display the same result whenever the truck number is the same for table 1 and table 2
 
Upvote 0
Re: EXCEL PROBLEM Need a function to add values whenever there are same truck numbers

Hi, OK - something like this:


Excel 2013
ABCDEFGHIJK
1TruckSmallBigTotalResultTruckSmallBigTotalResult
2877336146314932.08773366156768232
3843501134694144055.431194440010050075
4345201390739728.48391331331125145656
53119445005055075.03076125828266447.4
Sheet1
Cell Formulas
RangeFormula
E2=(D2+SUMIFS(J:J,G:G,A2))/IF(LEFT(A2)="8",26,14)
 
Upvote 0
Re: EXCEL PROBLEM Need a function to add values whenever there are same truck numbers

Yes, that's exactly what I needed

Thank you very much! you don't understand how much easier you just made my life haha
 
Upvote 0

Forum statistics

Threads
1,223,268
Messages
6,171,099
Members
452,379
Latest member
IainTru

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