Hi,
Just working on a spreedsheet and have got a bit stuck.
i am using this code below that i was told a very long time ago by Paddy i think, but have just tryed to use it for a different use and having problems.
Heres the code
Function EXTRACTNUMBER(TARGET As Range, Optional NUM As Boolean = True) As Variant
Dim n, TmpVal
If TARGET.Cells.Count > 1 Or Len(TARGET) < 1 Then
EXTRACTNUMBER = CVErr(1)
Exit Function
End If
For n = 1 To Len(TARGET)
If NUM = True Then
Select Case Mid(TARGET, n, 1)
Case 0 To 9: EXTRACTNUMBER = EXTRACTNUMBER & Mid(TARGET, n, 1)
End Select
Else
Select Case Mid(TARGET, n, 1)
Case 0 To 9:
Case Else: EXTRACTNUMBER = EXTRACTNUMBER & Mid(TARGET, n, 1)
End Select
End If
Next n
End Function
The problem i am having is as follows:
I have a list of data that is in currency form Eg: $US320.00
I want to extract the number but keep it as currency, what i am finding is that this code turns it into something like this: 32000 instead of 320.00
Is any one able to enlighten me on how to extract the $US part but have it stay in currency form to be added with many other curencys?
i tryed using another formula i found in excel help where it takes away as many digits as you want either from the right or the left using the LEN function but for some reason after using that if i added multiple entries that had been sifted with the formula the answer was always 0
In advance Thankyou for your time!
Timothy
Just working on a spreedsheet and have got a bit stuck.
i am using this code below that i was told a very long time ago by Paddy i think, but have just tryed to use it for a different use and having problems.
Heres the code
Function EXTRACTNUMBER(TARGET As Range, Optional NUM As Boolean = True) As Variant
Dim n, TmpVal
If TARGET.Cells.Count > 1 Or Len(TARGET) < 1 Then
EXTRACTNUMBER = CVErr(1)
Exit Function
End If
For n = 1 To Len(TARGET)
If NUM = True Then
Select Case Mid(TARGET, n, 1)
Case 0 To 9: EXTRACTNUMBER = EXTRACTNUMBER & Mid(TARGET, n, 1)
End Select
Else
Select Case Mid(TARGET, n, 1)
Case 0 To 9:
Case Else: EXTRACTNUMBER = EXTRACTNUMBER & Mid(TARGET, n, 1)
End Select
End If
Next n
End Function
The problem i am having is as follows:
I have a list of data that is in currency form Eg: $US320.00
I want to extract the number but keep it as currency, what i am finding is that this code turns it into something like this: 32000 instead of 320.00
Is any one able to enlighten me on how to extract the $US part but have it stay in currency form to be added with many other curencys?
i tryed using another formula i found in excel help where it takes away as many digits as you want either from the right or the left using the LEN function but for some reason after using that if i added multiple entries that had been sifted with the formula the answer was always 0
In advance Thankyou for your time!
Timothy