Avatar of Jase Alexander
Jase Alexander
Flag for United Kingdom of Great Britain and Northern Ireland

asked on 

Excel VBA extracting value from a text string with inconsistent formatting

Hey Guys
Hope you can help
Is there a way to search within a text statement for part of the string that contains a number or specifically, in this case, a value?
We have a system that has a comments section and in this section, the user posts a comment (manually however the date is auto-created) that basically details payment approval, invoice reference with its quantity and value. This comments is then pulled from our system into an Excel worksheet against the relevant record.
My only issue is that the statement isn’t always consistent in terms of the formatting and spacing between each section, and although going forward, I have managed to standardise the way in which this has been posted, historically I need to extract certain data from these posts to assist in automating a linked process.
Please see some examples below taken from our system that shows the inconsistency in posting:-
09/06/2016 – Approved for payment         invoice number YC1564
      Pieces : 5416                                  Value : $57146,54

10/10/2016 – Approved for payment           invoice ref 1657/SS13
                 Pieces : 10142                                 Value : £4213.06

09/01/2017 – Approved for payment           Invoice no. 11312/JCB
                   Pieces : 500                                Value : 324.01 EUR

What I need is to extract the figure entered after the Value label (the currency etc is not an issue) – is this possible via a formula or VBA considering the format is not always the same? For example, for the first comment above, the result would be 57146.54.
If the whole comment is held in Cell A1 for example, what could I put into Cell P1 to extract this data? I have attached a really basic file to show how the comments is situated within the worksheet (albeit in a different location)
Your suggestions, as always, would be extremely welcome

J
EE_Example.xlsx
VBAMicrosoft ExcelMicrosoft Office

Avatar of undefined
Last Comment
Jase Alexander

8/22/2022 - Mon