Which formula to extract part of the text ?

Inacio11

New Member
Joined
Jul 3, 2018
Messages
36
Hi there
How to extract through formula just the numbers highlighted in red color mark ? Take into consideration sometimes the currency appears as "R$" and others just "R ". Thanks in advance !

[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD] (VisaPlatin )Santander Informa: Compra APROVADA Cartao VISA final 0292 de R 38,90 em 23/08/18 as 15:12 BBB MODAS INFANTIS[/TD]
[/TR]
[TR]
[TD]{VisaPlatin}Santander Informa: Compra APROVADA Cartao VISA final 9153 de R$ 162,01 em 23/08/18 as 20:02 POSTO HIGIENOPOLIS[/TD]
[/TR]
[TR]
[TD]Gastos em Moeda: Cantina educandario R$ 20,00[/TD]
[/TR]
[TR]
[TD]ITAU PERSONNALITE: Cartao final 0512 COMPRA APROVADA 26/08 12:41:06 R$ 9,40 Local: PAD BRASI.[/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
Hi,

Use B1 formula to return results as Text.
Use C1 formula to convert results to Real Numbers. (my sample shows #VALUE ! errors because my regional settings uses the Decimal rather than Comma)


Book1
ABC
1(VisaPlatin )Santander Informa: Compra APROVADA Cartao VISA final 0292 de R 38,90 em 23/08/18 as 15:12 BBB MODAS INFANTIS38,90[URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=VALUE]#VALUE[/URL] !
2{VisaPlatin}Santander Informa: Compra APROVADA Cartao VISA final 9153 de R$ 162,01 em 23/08/18 as 20:02 POSTO HIGIENOPOLIS162,01[URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=VALUE]#VALUE[/URL] !
3Gastos em Moeda: Cantina educandario R$ 20,0020,00[URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=VALUE]#VALUE[/URL] !
4ITAU PERSONNALITE: Cartao final 0512 COMPRA APROVADA 26/08 12:41:06 R$ 9,40 Local: PAD BRASI.9,40[URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=VALUE]#VALUE[/URL] !
Sheet210
Cell Formulas
RangeFormula
B1=TRIM(MID(SUBSTITUTE(MID(A1,FIND(" R$ ",SUBSTITUTE(A1," R "," R$ "))+1,255)," ",REPT(" ",15)),15,15))
C1=MID(SUBSTITUTE(MID(A1,FIND(" R$ ",SUBSTITUTE(A1," R "," R$ "))+1,255)," ",REPT(" ",15)),15,15)+0
 
Upvote 0
Hi jtakw
Thanks for early repply.
It works !!! :)

As I need the values as number I chose the solution "C1".
By the way I found a new situation that it is not recognized by the proposed formula:
Itau Personnalite: realizada transferencia entre contas no valor de R$30,00 em 12/08 as 11:38. Conta debitada: XXX87-7.
See on this case the currency "R$" is adjacent of the number.
Could you please update the formula to also cover this new one situation ?
Thanks !
 
Upvote 0
Ok, it seems we can't reliably use the " R " & " R$ " as the delimiter, since there's a chance of " R$", there may Also be a chance of " R" where the numbers and directly behind without Any Space.
So I'm using a different approach, hopefully, your strings only contain 1 currency value:


Book1
ABC
1(VisaPlatin )Santander Informa: Compra APROVADA Cartao VISA final 0292 de R 38,90 em 23/08/18 as 15:12 BBB MODAS INFANTIS38,90#VALUE!
2{VisaPlatin}Santander Informa: Compra APROVADA Cartao VISA final 9153 de R$ 162,01 em 23/08/18 as 20:02 POSTO HIGIENOPOLIS162,01#VALUE!
3Gastos em Moeda: Cantina educandario R$ 20,0020,00#VALUE!
4ITAU PERSONNALITE: Cartao final 0512 COMPRA APROVADA 26/08 12:41:06 R$ 9,40 Local: PAD BRASI.9,40#VALUE!
5Itau Personnalite: realizada transferencia entre contas no valor de R$30,00 em 12/08 as 11:38. Conta debitada: XXX87-7.30,00#VALUE!
6Itau Personnalite: realizada transferencia entre contas no valor de R30,00 em 12/08 as 11:38. Conta debitada: XXX87-7.30,00#VALUE!
Sheet210
Cell Formulas
RangeFormula
B1=TRIM(RIGHT(SUBSTITUTE(SUBSTITUTE(LEFT(A1,FIND(",",A1)+2),"R$",REPT(" ",15)),"R",REPT(" ",15)),15))
C1=RIGHT(SUBSTITUTE(SUBSTITUTE(LEFT(A1,FIND(",",A1)+2),"R$",REPT(" ",15)),"R",REPT(" ",15)),15)+0


Same description as Post #2 .
 
Upvote 0
Assuming that your string ..
- only contains one currency value
- that currency value is always expressed as a decimal (like all you samples)
- if the currency can be 1000 or greater there is no thousands separator (can adjust that if required)
- contains no other commas (like all your samples)
(I think jtakw also assumed all these things?)

.. then I think this should also work for you (up to 999999.99 & if bigger numbers required, add a few more into {4,5,6,7,8,9,....})
Code:
=AGGREGATE(14,6,RIGHT(LEFT(A1,FIND(",",A1)+2),{4,5,6,7,8,9})+0,1)
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,819
Messages
6,181,153
Members
453,021
Latest member
Justyna P

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