A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Excel » Worksheet Functions
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

How can I extract the second half of addition ?



 
 
Thread Tools Display Modes
  #1  
Old September 28th, 2008, 06:04 PM posted to microsoft.public.excel.worksheet.functions
Gilbert DE CEULAER
external usenet poster
 
Posts: 25
Default How can I extract the second half of addition ?

I have lots of entries that have the form "+6+2", "+4+3", "+5+1".
Is there any way to extract the second half, so the "+2", "+3", "+1" - part
?
(Not all of the entries concerned are like that; somre simply read "+6",
"+3", "+2"; in that case the extraction should read "0")
Thanks in advance,
Gilbert


  #2  
Old September 28th, 2008, 06:28 PM posted to microsoft.public.excel.worksheet.functions
T. Valko
external usenet poster
 
Posts: 15,759
Default How can I extract the second half of addition ?

Try this:

=IF(LEN(A1)-LEN(SUBSTITUTE(A1,"+",""))2,0,MID(A1,FIND("+",A1, FIND("+",A1)+1),10))

--
Biff
Microsoft Excel MVP


"Gilbert DE CEULAER" wrote in message
...
I have lots of entries that have the form "+6+2", "+4+3", "+5+1".
Is there any way to extract the second half, so the "+2", "+3", "+1" -
part ?
(Not all of the entries concerned are like that; somre simply read "+6",
"+3", "+2"; in that case the extraction should read "0")
Thanks in advance,
Gilbert




  #3  
Old September 28th, 2008, 06:37 PM posted to microsoft.public.excel.worksheet.functions
franciz
external usenet poster
 
Posts: 23
Default How can I extract the second half of addition ?

Assuming your data is in col A, you may use the Right function to extract
"+2","+3","+1" from your examples given.

place this in B1 and drag down as far as you need

=RIGHT(A1,2)

Does this do what you want?

regards,

"Gilbert DE CEULAER" wrote:

I have lots of entries that have the form "+6+2", "+4+3", "+5+1".
Is there any way to extract the second half, so the "+2", "+3", "+1" - part
?
(Not all of the entries concerned are like that; somre simply read "+6",
"+3", "+2"; in that case the extraction should read "0")
Thanks in advance,
Gilbert



  #4  
Old September 28th, 2008, 06:51 PM posted to microsoft.public.excel.worksheet.functions
franciz
external usenet poster
 
Posts: 23
Default How can I extract the second half of addition ?

I have expand the formula to include "0" if your data shows only "+6" instead
of
"+6+2"

Place this in B1 and drag down

=IF(RIGHT(A3,2)=A3,"0",(RIGHT(A3,2)))

Hope this is of help

regards,





"franciz" wrote:

Assuming your data is in col A, you may use the Right function to extract
"+2","+3","+1" from your examples given.

place this in B1 and drag down as far as you need

=RIGHT(A1,2)

Does this do what you want?

regards,

"Gilbert DE CEULAER" wrote:

I have lots of entries that have the form "+6+2", "+4+3", "+5+1".
Is there any way to extract the second half, so the "+2", "+3", "+1" - part
?
(Not all of the entries concerned are like that; somre simply read "+6",
"+3", "+2"; in that case the extraction should read "0")
Thanks in advance,
Gilbert



  #5  
Old September 28th, 2008, 06:55 PM posted to microsoft.public.excel.worksheet.functions
Gilbert DE CEULAER
external usenet poster
 
Posts: 25
Default How can I extract the second half of addition ?

Sorry, Biff, but if A1 = "=7+2", the result is 0, where I want "2" or "+2"

"T. Valko" wrote in message
...
Try this:

=IF(LEN(A1)-LEN(SUBSTITUTE(A1,"+",""))2,0,MID(A1,FIND("+",A1, FIND("+",A1)+1),10))

--
Biff
Microsoft Excel MVP


"Gilbert DE CEULAER" wrote in message
...
I have lots of entries that have the form "+6+2", "+4+3", "+5+1".
Is there any way to extract the second half, so the "+2", "+3", "+1" -
part ?
(Not all of the entries concerned are like that; somre simply read "+6",
"+3", "+2"; in that case the extraction should read "0")
Thanks in advance,
Gilbert






  #6  
Old September 28th, 2008, 06:55 PM posted to microsoft.public.excel.worksheet.functions
muddan madhu
external usenet poster
 
Posts: 695
Default How can I extract the second half of addition ?

try this

=IF(ISERROR(MID(A1,FIND("+",A1,2),255)),0,MID(A1,F IND("+",A1,2),255))

On Sep 28, 10:04*pm, "Gilbert DE CEULAER"
wrote:
I have lots of entries that have the form "+6+2", "+4+3", "+5+1".
Is there any way to extract the second half, so the "+2", "+3", "+1" - part
?
(Not all of the entries concerned are like that; somre simply read "+6",
"+3", "+2"; in that case the extraction should read "0")
Thanks in advance,
Gilbert


  #7  
Old September 28th, 2008, 06:57 PM posted to microsoft.public.excel.worksheet.functions
Gilbert DE CEULAER
external usenet poster
 
Posts: 25
Default How can I extract the second half of addition ?

Sorry, Franciz, but "=4+4" gives "8", instead of "4" or "+4"
And what about the entries without a second part ?

"franciz" wrote in message
news
Assuming your data is in col A, you may use the Right function to extract
"+2","+3","+1" from your examples given.

place this in B1 and drag down as far as you need

=RIGHT(A1,2)

Does this do what you want?

regards,

"Gilbert DE CEULAER" wrote:

I have lots of entries that have the form "+6+2", "+4+3", "+5+1".
Is there any way to extract the second half, so the "+2", "+3", "+1" -
part
?
(Not all of the entries concerned are like that; somre simply read "+6",
"+3", "+2"; in that case the extraction should read "0")
Thanks in advance,
Gilbert





  #8  
Old September 28th, 2008, 06:59 PM posted to microsoft.public.excel.worksheet.functions
Ron Rosenfeld
external usenet poster
 
Posts: 3,719
Default How can I extract the second half of addition ?

On Sun, 28 Sep 2008 19:04:54 +0200, "Gilbert DE CEULAER"
wrote:

I have lots of entries that have the form "+6+2", "+4+3", "+5+1".
Is there any way to extract the second half, so the "+2", "+3", "+1" - part
?
(Not all of the entries concerned are like that; somre simply read "+6",
"+3", "+2"; in that case the extraction should read "0")
Thanks in advance,
Gilbert


You could use a User Defined Function.

This assumes you have provided inclusive examples of the format of your
entries. If you have not, we will need to change re.Pattern.

pattern: Quotes | + | digit(s) | + | digit(s) | quotes | end-of-line

alt-F11 opens the VB Editor.
Ensure your project is highlighted in the Project Explorer window, then
Insert/Module and paste the code below into the window that opens.

Insert/Module and paste the code below into the window that opens.

Use a formula =LastPlus(cell_ref) where cell_ref is the address of a cell
containing your string.

==================================
Option Explicit
Function LastPlus(str As String) As Variant
Dim re As Object, mc As Object
Set re = CreateObject("vbscript.regexp")
re.Pattern = "(\d)(\+\d+(?=""$))"
If re.test(str) = True Then
Set mc = re.Execute(str)
LastPlus = mc(0).submatches(1)
End If

End Function
=================================
--ron
  #9  
Old September 28th, 2008, 07:10 PM posted to microsoft.public.excel.worksheet.functions
RagDyeR
external usenet poster
 
Posts: 3,482
Default How can I extract the second half of addition ?

Are those entries actual *working formulas*?
--
Regards,

RD

---------------------------------------------------------------------------
Please keep all correspondence within the NewsGroup, so all may benefit !
---------------------------------------------------------------------------
"Gilbert DE CEULAER" wrote in message
...
Sorry, Biff, but if A1 = "=7+2", the result is 0, where I want "2" or "+2"

"T. Valko" wrote in message
...
Try this:


=IF(LEN(A1)-LEN(SUBSTITUTE(A1,"+",""))2,0,MID(A1,FIND("+",A1, FIND("+",A1)+1
),10))

--
Biff
Microsoft Excel MVP


"Gilbert DE CEULAER" wrote in message
...
I have lots of entries that have the form "+6+2", "+4+3", "+5+1".
Is there any way to extract the second half, so the "+2", "+3", "+1" -
part ?
(Not all of the entries concerned are like that; somre simply read

"+6",
"+3", "+2"; in that case the extraction should read "0")
Thanks in advance,
Gilbert







  #10  
Old September 28th, 2008, 07:12 PM posted to microsoft.public.excel.worksheet.functions
Gilbert DE CEULAER
external usenet poster
 
Posts: 25
Default How can I extract the second half of addition ?

Sorry, Muddan, but "=4+2" gives 0, instead of "2" or "+2"

"muddan madhu" wrote in message
...
try this

=IF(ISERROR(MID(A1,FIND("+",A1,2),255)),0,MID(A1,F IND("+",A1,2),255))

On Sep 28, 10:04 pm, "Gilbert DE CEULAER"
wrote:
I have lots of entries that have the form "+6+2", "+4+3", "+5+1".
Is there any way to extract the second half, so the "+2", "+3", "+1" -
part
?
(Not all of the entries concerned are like that; somre simply read "+6",
"+3", "+2"; in that case the extraction should read "0")
Thanks in advance,
Gilbert



 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 02:15 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.