Extract data after "-" VBA

Liam4567

New Member
Joined
Jan 6, 2021
Messages
6
Office Version
  1. 365
Platform
  1. Windows
**VBA**

Hi

I have a string that will change daily and looks something like this "09876 k-wef234 £45678.99 Option 4 -£123456.57"

I am trying to find the best way of extracting the "-£123456.57" after "Option 4 -£123456.57". I need the code to always look for Option 4 as that is the one part that will always stay the same, and the number after will always start with a minus. It needs to look for Option 4 as it is going to loop through multiple rows of data looking for the words Option 4.

I will then be using that figure (-£123456,57) to be the value of a cell on another sheet.

Thanks in advance.
 
So there will only be one cell in column A containing "Option 4"?
Yes correct :)

There will be lots or rows containing data, and some may say Option 5, but only one will contain 'Option 4' and then I just need the figure after that into cell D2 on sheet2, and that figure will always start with a -
 
Upvote 0

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
I edited my previous post. Does the edit answer your question?
 
Upvote 0
So there will only be one cell in column A containing "Option 4"?

Edit:
If so, do you really need vba for this or would a formula like this do?

Excel Formula:
=-RIGHT(SUBSTITUTE(VLOOKUP("*Option 4*",PDF!A1:A1000,1,0),"£",REPT(" ",20)),20)
That worked, thanks for your help :)
 
Upvote 0
You're welcome. Glad we got there in the end. :)
 
Upvote 0

Forum statistics

Threads
1,214,833
Messages
6,121,862
Members
449,052
Latest member
Fuddy_Duddy

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