Let’s say I have a column wherein there are blank rows and rows that combine text and numbers. For example, A1 might look like "some text (2)", A2 might contain "some more text (7)", A3 might be blank and A4 look like A1 and A2. I would like to be able to quickly find the sum of the numbers in between the parentheses in column A. I have figured out how to use the MID, LEFT, and FIND functions to extract the values from each string, but getting their sum amounts to an extremely long formula (considering the column might contain as many as twenty such cells). This is what I have been using:
SUM(IFERROR(MID(LEFT(A1,FIND(")",A1)-1),FIND("(",A1)+1,LEN(A1)), 0) +
IFERROR(MID(LEFT(A2,FIND(")",A2)-1),FIND("(",A2)+1,LEN(A2)), 0)+...
And so on, down to the last desired row. This is far too tedious. Is there a shorter way?
You can use an array formula:
=SUM(1*IFERROR(MID(LEFT($A$1:$A$20,
FIND(")",$A$1:$A$20)-1),FIND("(",$A$1:$A$20)+1,LEN($A$1:$A$20)), 0))
Enter using Ctrl+Shift+Enter
E.g:
Related
I'm trying to create a formula in column K which sums all cells that apply , in column J, only when the following conditions are true:
dates are the same in column A
AND client name is the same in column B
For example, in cell K2, I want the sum of J2+J3+J4 because A2=A3=A4 and B2=B3=B4.
K5=J5 only, because there are no other dates with the same client name.
K6=J6+J7 because A6=A7 and B6=B7.
What kind of formula would I use for this? I can't figure out how to do it with a SUMIFS.
I would try using a pivot table with:
The names as row values
The dates as the column values
And funds received using SUM in the values column
Edit
Based on #pnuts comments here is how to get the values in column K. Put this in K2 and drag down.
=IF(OR(COUNTIFS($B$1:B3, B3) = 1, B3 = ""), SUMIFS($J$2:J2, $A$2:A2, A2, $B$2:B2, B2), "")
This formula will give blank values until the formula finds a new client on a new date. However, I still think using pivot table is a better solution.
However, I still find the pivot table
In cell K2 put following formula:
=IF(COUNTIFS($A$2:A2,A2,$B$2:B2,B2)=1,SUMIFS($J$2:$J$10,$A$2:$A$10,A2,$B$2:$B$10,B2),"")
Adjust row 10 value. It will be last row of your actual data.
Copy down as much you need.
EDIT
Uploaded file shows the cause behind formula not working correctly for you. It turned out to be whitespace characters in column B (names) data e.g.
Cell B3: "Moe John" has a trailing space.
Cell B10: Same case with "Doe Jane"
If you want to use above posted formula then all names shall be corrected. Or alternatively to deal with spaces you can adopt below approach.
=IF(COUNTIFS($A$2:A2,A2,$B$2:B2,"*"&TRIM(B2)&"*")=1,SUMIFS($J$2:$J$28,$A$2:$A$28,A2,$B$2:$B$28,B2),"")
Notice the change in COUNTIFS formula where B2 is now replaced with "*"&TRIM(B2)&"*".
Even such formula will take a beating if you have uneven whitespace characters in between your data. I'd suggest normalizing it as much as possible.
I've got a cell range A1:A10 containing single letters or short strings like "GEPR", "GE" etc. and want to count every cell containing a G.
I tried
=IFERROR(IF(FIND("G";A1);1);0)
but this writes a 1 into each row and doesn't output the sum of cells containing a "G". Furthermore if I want to count for another letter (e.g. "E") I need more space in the worksheet. Is there a more convenient function like COUNTIF which just needs one cell for each leter?
You can use SUMPRODUCT together with FIND to do this.
=SUMPRODUCT(--NOT(ISERROR(FIND("G",$A$1:$A$10))))
This basically counts for how many values in A1:A10 the FIND function does not return an error.
Assuming you don't care about case just use COUNTIF with "wildcards", e.g. for the number of cells in your range containing a "G"
=COUNTIF(A$1:A$10,"*G*")
If you want to use a cell reference for the criterion, e.g. with C2 containing "G" you can use this version:
=COUNTIF(A$1:A$10,"*"&C2&"*")
You might put the letters of interest in Row1 (staring at B) and in B2 and copied across:
=SUM(IFERROR(IF(FIND(B$1;$A2:$A11);1);0))
entered with Ctrl+Shift+Enter.
When a cell in A2:A100 meets a certain condition, I want to multiply a corresponding value by a factor and, for a different condition, the corresponding value by a different factor, eg when A2=:
"Banana" then B2*C2 but when
"Apple" then B2*C3 but when
"Pear" then B2*C4
and sum these results, all in a single cell.
So when A2="Banana" and A3="Pear" I want to have this: =B2*C2+B3*C4.
The corresponding values for the criteria in ColumnA are in ColumnB (matching row) and C2, C3 and C4 contain the factors appropriate to the criteria.
I have tried a big formula, but that took me like forever, and when I enter more values in ColumnA I have to adjust that formula.
Please try:
=SUMIF(A:A,"Apple",B:B)*C3+SUMIF(A:A,"Banana",B:B)*C2+SUMIF(A:A,"Pear",B:B)*C4
oops - but with semicolons instead of commas!
=IF(A2="banana";B2*C2;IF(A2="apple";B2*C3;B2*C4))
or do you need something simular but for 100+ cases?
IN B1 I have: 3,4,5
IN B2 I have the sum of these numbers 12
I would like to add these together and the sum to appear in B3
So, for B3, I need to tell excel to reference the cell holding the numbers, then add them together. This way, once I create the original formula, I can drag it through the remaining cells.
Reason is: The sum of these numbers (B2), are pulling the sum from a different location within the spreadsheet. I need to make sure these numbers match.
Thank you
Alternate solution (if exactly three numbers separated by a comma):
=SUMPRODUCT(--MID(SUBSTITUTE(B1,",",REPT(" ",99)),99*(ROW($1:$3)-1)+1,99))
Or, to make the formula more dynamic so that the B1 cell can have any quantity of numbers, as long as they are separated by a comma:
=SUMPRODUCT(--MID(SUBSTITUTE(B1,",",REPT(" ",99)),99*(ROW(INDIRECT("1:"&LEN(B1)-LEN(SUBSTITUTE(B1,",",""))+1))-1)+1,99))
Assuming you always have three numbers separated by a coma.
=LEFT(B1,FIND(",",B1)-1) + MID(B1,FIND(",",B1)+1,FIND(",",B1,FIND(",",B1)+1)-FIND(",",B1)-1) + MID(B1,FIND(",",B1,FIND(",",B1,FIND(",",B1)+1))+1,100)
If I break down the formula it's a bit simpler to see what is going on.
1st number:
LEFT(B1,FIND(",",B1)-1)
2nd number:
MID(B1,FIND(",",B1)+1,FIND(",",B1,FIND(",",B1)+1)-FIND(",",B1)-1)
3rd number:
MID(B1,FIND(",",B1,FIND(",",B1,FIND(",",B1)+1))+1,100)
Example, for the word apple. I want the output to be
apple
a.pple
a.p.ple
and so on. I need to get all the possibilities. The only rule is it can't have two periods in a row and also no periods at the end or start.
How can I do this in excel? Even a simple .txt would be okay as well.
This can be done in Excel by using string formulas. This is what my worksheet looks like:
The formula in cell B2 is: =LEFT($A$1,A2)&"."&MID($A$1,A2+1,5)
Cell A1 has the string "apple", and cell A2 has the integer 0, B2 has the string ".apple" (which you don't want, so you can ignore this value). I drag down the column of integers in column A from 0 to 5.
The "LEFT" formula takes the leftmost characters of a string, and then i insert the period between this and the following characters which are brought in using the MID formula. Since the input for LEFT and MID is the integer value in column A, this will output in column B every such combination you are looking for. Note you MUST lock cell A1 in this formula, as the string will always be in cell A1.
Hope this helps!