Combine cells matching data into one cell - excel

Is there any VBA code or complicated excel function that would assist with what I need done? I export thousands of ref#s with check#s that need to be combined into one cell with the correspond check #. I know I can combine text, and I could probably use a VLUP function with it, but I'm not sure of the exact function string that should be used.
Basically, rows A2:A4 all share the check# 999, so when I run the script or input the function, it should combine in row C2 the ref#s 1 2 3. In the next chk# row it would combine reference#s 4 5, so on and so on (example is in the table below). All separated with spaces. Is this possible? It is very tedious to do it all by hand.
Example...
Ref # Chk # Combined #
1 999 1 2 3
2 999
3 999
4 1000 4 5
5 1000
6 1001 6
7 1002 7
8 1003 8
9 1004 9 10 11 12
10 1004
11 1004
12 1004
13 1005 13 14
14 1005

For a formula answer without the need for vba.
Use a helper column. So in C2 put:
=IF(B2<>B3,A2,A2 & " " & C3)
Then in D2 put:
=IF(B2<>B1,C2,"")
And copy both down.
Then you can hide C.

Related

Formula reference holds for n cells in a row, then switches to new reference

I wonder if there's a quick solution to the following:
My goal is to divide a cell value by three, using the same value for three cells in a row, then switch to the next value in the series for another three cells in a row, and so on.
So my starting data would look like:
A B C D E
1 9 12 6 21 27
2 30 9 3 0 3
3 ...
I want the new cells to look like:
AA AB AC AD AE ...
1 3 3 3 4 4
2 10 10 10 3 3
...
Where the cell AA1 = A1/3, AB1 = A1/3, AC1 = A1/3, but AD1 = B1/3 and so on.
I need to do this for many observations, preferably using an excel formula.
Does anyone have any ideas on quick solutions?
Really appreciate your help.
Best,
Henry
Use INDEX:
=INDEX(1:1,0,ROUNDUP(COLUMN(A1)/3,0))/3

Subtotals grouped by value using COUNTIF to create ranges for SUMIF, but in a single formula

End-goal: A column with the subtotals of groups (defined in the below table as all foods listed above Zucchini, incl Zucchini).
Current attempt: create a column to define groups using COUNTIF('count all 'zucchini' thus far'). Then use SUMIF to get the total cost for the current group.
Problem: I don't know how to do this without the COUNTIF column (since SUMIF needs range C:C to be resolved first). I'd like to have it in a single formula. I looked into array formulas but not sure if/how to apply that here.
FOOD COST COUNTIF(A2:A$2;"Zucchini") SUMIF(C:C;C2;B:B)
Apple 3 0 12
Pecan 7 0 12
Zucchini 2 0 12
Apple 4 1 23
Olive 8 1 23
Pecan 6 1 23
Zucchini 5 1 23
Apple 4 2 16
Olive 9 2 16
Zucchini 3 2 16
Any ideas on how to solve either the current problem or the end-goal problem? Thanks!
Put this in C2 and copy down:
=IF(A2="Zucchini",SUM($B$1:B2)-SUM($C$1:C1),"")
It basically sums everything to the row and subtracts what is already accounted for.

Excel using SUMIF to calculate totals of multiple columns

I'm trying to use Excle's SUMIF to calculate totals of Col1 to Col5 for dates that are similar.
My formula is as follows =SUMIF($A2:$A7,A10,$B2:$F7), but this only gives me the total of a single column.
How can I get the Totals of all the columns based on the date like I've shown in my results.
Date Col 1 Col 2 Col 3 Col 4 Col 5
1/5/2017 1 2 2
1/5/2017 5 3 1
1/5/2017 9 5 5
2/5/2017 10 5 3
2/5/2017 20 10 3
2/5/2017 6 8 1 5
Desired Results
1/5/2017 15 7 7 3 1
2/5/2017 30 11 11 11 8
use below formula in cell B11
=SUMIF($A$2:$A$7,$A11,B$2:B$7)
Per the example you provided, One solution is to use SUMPRODUCT
Multiplies corresponding components in the given arrays, and returns the sum of those products
Microsoft Docs give a thorough example, but per SO etiquette, here is an example in case of link-rot: [FYI, I used absolute reference for easier filling across, arbitrary how you get it done though]
Forumlas shown:
Formula is kind of hard to see without clicking on image:
=SUMPRODUCT(($B$3:$B$8=$B$11)*C3:C8)
This basically breaks down like this, it searches the B:B column for a match, and it will naturally return a true or false for the match, or 0/1 counterparts, and multiplys that by the number found in the column to the right (C3:C8), so it will either be 1 * # = # or 0 * # = 0

"The formula refers to a range" error in Excel

Am new to Excel, please help me with this:
A B
2 9 =IF(A2:A6>=7,"1","0")
3 4
4 7
5 4
6 5
For B2 the formula works perfectly fine but in B3 it selects from A3:A6.
I know the concept of Absolute referencing. But here in this example it should basically work without any errors, right?
A B c
2 9 1 =Sum(A2:B2)
3 4 2
4 7 33
5 4 3
6 5 22
The above example works fine. What is the difference between two?
If you want the A2:A6 range to float down as you copy the formula to other rows, use:
=IF(MAX(A2:A6)>=7, 1, 0)
However, if you want row 6 locked as the finite terminator of the range then lock it as absolute with a $ like this,
=IF(MAX(A2:A$6)>=7, 1, 0)
        

How to add up values in Excel while ignoring missing values (encoded 999)?

Please consider the following Excel worksheet:
A B C D E F
---------------------------
1 10 5 999 999 10 25
2 5 1 10 999 5 21
3 5 1 100 1 5 112
What I need is a formula in each cell of column Fto add up the values of each row, whilst ignoring 999 values. So usually the formula in cell F1 would be:
=SUM(A1:F1)
But this obviously returns 2048, not 25. So my question: what formula will add up all values, ignoring 999 (missing) values?
Extending from comment (and thanks to #SiddharthRout):
You can use
=SUMIF(A1:E1,"<>999")
in column F.

Resources