Column A
26||12may09||some
4||30june10||text
122||6Jan02||here
54||22may04||whatever
Hi,
Would it be possible to sum the first part (the number on the left of the separator ||) of a string in a cell ?
tnchong
Column A
26||12may09||some
4||30june10||text
122||6Jan02||here
54||22may04||whatever
Hi,
Would it be possible to sum the first part (the number on the left of the separator ||) of a string in a cell ?
tnchong
Sorry, I mean
Would it be possible to sum the first part (the number on the left of the separator ||) of a string in a column of cell ?
Try this
=SUM(--LEFT(A1:A4,FIND("|",A1:A4)-1))
Commit with Ctrl+Shift+Enter
It would be far better if the data were already separated into columns.
Entia non sunt multiplicanda sine necessitate
Regards --
This is known as the double unary operator and is used to coerce a number stored as text to a number, ie --"10" becomes 10
Regards CTRL + SHIFT + ENTER
This is an Array formula and is often referred to as a CSE formula ... see the link in my sig to Colin_L's Array tutorial/discussion for a more in depth review on the subject.
You could possibly revert to a SUMPRODUCT (normal ENTER entry) over a SUM CSE, eg the below mimics the previously detailed CSE:
=SUMPRODUCT(--(LEFT(A1:A4,FIND("|",A1:A4)-1)))
however both the CSE & the above SUMPRODUCT are in their present form are however open to error if any cell within A1:A4 fails to contain the pipe symbol and/or entry contains alpha text only.
In this regard the previously detailed SUMPRODUCT could be strengthened slightly to:
=SUMPRODUCT(--(LEFT("0"&A1:A10,FIND("|","0"&A1:A10&"|")-1)))
However should the range contain non-numerics pre pipe then it would still generate an error.
Last edited by DonkeyOte; 05-16-2009 at 02:56 AM.
My Recommended Reading:
Volatility
Sumproduct & Arrays
Pivot Intro
Email from XL - VBA & Outlook VBA
Function Dictionary & Function Translations
Dynamic Named Ranges
Or you can select your data and DATA->TEXT TO COLUMNS-> delimited -> in other write |
And you'll get separated data for numbers, dates and data
Never use Merged Cells in Excel
Column A
26||12may09||brad
4||30june10||
37||6Jan02||here
54||22may04||whatever
2||16Jan05||here
54||12may08||pitt
26||2may99||
4||7june01||text
Hi,
I would like to make a little bit of amendment here. How can I conditionally sum the numbers on the left of the sepator when seeing the word "here" on the right side of the sepator. i.e. only 37 and 2 should be added.
Any bright ideas eh ?
This formula will inore the text and sum only number on left side of pipe symbol
Don't forget to press CSE (Ctril + Shift + Enter)
{=SUM(IF(ISNUMBER(--LEFT(A1:A4,FIND("|",A1:A4)-1)),(--LEFT(A1:A4,FIND("|",A1:A4)-1)),0))}
If this post helps, Please don't 4get to click the star icon located at the bottom left of my Post.
I would opt for:
=SUMPRODUCT(--(RIGHT(A1:A10,5)="|here"),--(LEFT("0"&A1:A10,FIND("|","0"&A1:A10&"|")-1)))
The 2nd result can be achieved with this .... But i think Sumproduct is good approach if you have some knowledge about it .......
Don't forget to press CSE (Ctril + Shift + Enter)
=SUM(IF(ISNUMBER(--LEFT(A1:A4,FIND("|",A1:A4)-1)),(--LEFT(A1:A4,FIND("|",A1:A4)-1)),0)*(--(RIGHT(A1:A4,5)="|here")))
To handle blanks...ie blanks become "0|"
(so you can apply the formula to a range containing blanks be they at the end or interspersed amongst other entries)
If you read the earlier posts all methods would still fail if a given cell in the range was non-blank but failed to contain a number in the left most section (ie "aaa") ... this could be accounted for but is most likely not required.
Last edited by DonkeyOte; 05-18-2009 at 03:40 AM.
Yes it would, apologies mubashir - I should have reviewed more thoroughly before casting dispersions![]()
A more powerfull approach if there is no match found ...
Don't forget to press (CSE)
@ DK No problem as you are one of those persons from forum bcoz of them I'm learning a lot=IF(SUM(IF(ISNUMBER(--LEFT(A1:A4,FIND("|",A1:A4)-1)),(--LEFT(A1:A4,FIND("|",A1:A4)-1)),0)*(--(RIGHT(A1:A4,5)="|here")))=0,"No Match Found",SUM(IF(ISNUMBER(--LEFT(A1:A4,FIND("|",A1:A4)-1)),(--LEFT(A1:A4,FIND("|",A1:A4)-1)),0)*(--(RIGHT(A1:A4,5)="|here"))))…..
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks