Trying2learnVBA
Board Regular
- Joined
- Aug 21, 2019
- Messages
- 67
- Office Version
- 365
- 2021
- Platform
- Windows
Hello,
I would like to extract the number after USD in this string:
I've tried different methods, formulas, some vba methods.
this is my current code and I can't get it to work. I get an error. It says variable not defined and the 'i' gets highlighted. Any ideas as to what i am doing wrong?
I would like to extract the number after USD in this string:
03-Oct-2022 Swap Net Coupon CME IRS Trade: 15360193 03-Oct-2022 USD 127,575.00 DB |
I've tried different methods, formulas, some vba methods.
this is my current code and I can't get it to work. I get an error. It says variable not defined and the 'i' gets highlighted. Any ideas as to what i am doing wrong?
VBA Code:
Function GetNumeric(CellRef As String)
Dim StringLength As Integer
StringLength = Len(CellRef)
For i = 1 To StringLength
If IsNumeric(Mid(CellRef, i, 1)) Then Result = Result & Mid(CellRef, i, 1)
Next i
GetNumeric = Result
End Function