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

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
Re: EXCEL PROBLEM Need a function to add values whenever there are same truck numbers

ABCDEFGHIJK
1TruckSmallBigTotalResultTruckSmallBigTotal Result
287733614631495.78773366156768226.2
3843501134694144055.431194440010050035.7
4345201390739728.48391331331125145656
53119445005055039.33076125828266447.4

<tbody>
</tbody>
 
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
1TruckSmallBigTotalResultNewTruckSmallBigTotalResult
287733614631495.78318773366156768226.2
38435011346941440102.9144031194440010050035.7
4345201390739728.43978391331331125145656
53119445005055039.310503076125828266447.4

<colgroup><col><col><col><col><col><col><col><col><col><col><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>
Database

Worksheet Formulas
CellFormula
F2=D2+SUMIFS(K:K,H:H,A2)

<thead>
</thead><tbody>
</tbody>

<tbody>
</tbody>

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
ABCDEFGHIJK
1TruckSmallBigTotalResultTruckSmallBigTotalResult
28773361463149328773366156768232
3843501134694144055.431194440010050075
4345201390739728.48391331331125145656
531194450050550753076125828266447.4

<tbody>
</tbody>

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,215,101
Messages
6,123,096
Members
449,096
Latest member
provoking

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