Extract a percentage from a text

L

Lok Tak Cheong

A1 is text: The increment is 5%
B1 is value and formula = 1000 * (increment in A1)
Can anyone help with this?
Thanks in advance,
Cheong
 
D

Dave Peterson

The number is always the last thing in the string and it always has a space
character before it?

If yes to both, then this returned 50 for me:

=1000*RIGHT(A1,LEN(A1)-FIND(CHAR(1),SUBSTITUTE(A1," ",CHAR(1),LEN(A1)
-LEN(SUBSTITUTE(A1," ","")))))
 
L

Lok Tak Cheong

Thanks a lot!
Dave Peterson said:
The number is always the last thing in the string and it always has a
space
character before it?

If yes to both, then this returned 50 for me:

=1000*RIGHT(A1,LEN(A1)-FIND(CHAR(1),SUBSTITUTE(A1," ",CHAR(1),LEN(A1)
-LEN(SUBSTITUTE(A1," ","")))))
 
L

Lok Tak Cheong

Dear Dave:
Could you please tell me what is the problem of this function?

Function efind(Find_value, Within_Text)
E = WorksheetFunction.Find(Find_value, Within_Text)
efind = WorksheetFunction.Mid(Within_Text, E - 1, 2)
End Function

Lok Tak Cheong said:
Thanks a lot!
 
G

Guest

Assuming the value is actually in the text being searched (also Find is case
sensitive), probably because VBA has it's own Mid function - so drop the
worksheetfunction.mid and change to just mid.

Function efind(Find_value, Within_Text)
E = WorksheetFunction.Find(Find_value, Within_Text)
efind = Mid(Within_Text, E - 1, 2)
End Function


Lok Tak Cheong said:
Dear Dave:
Could you please tell me what is the problem of this function?

Function efind(Find_value, Within_Text)
E = WorksheetFunction.Find(Find_value, Within_Text)
efind = WorksheetFunction.Mid(Within_Text, E - 1, 2)
End Function
 
D

Dave Peterson

And look at VBA's help for instr. It'll do the equivalent of the worksheet
function Find.
Dear Dave:
Could you please tell me what is the problem of this function?

Function efind(Find_value, Within_Text)
E = WorksheetFunction.Find(Find_value, Within_Text)
efind = WorksheetFunction.Mid(Within_Text, E - 1, 2)
End Function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top