dan_l
Active Member
So, I've got some really noisy, messy, bad data that I have to 'make useful'. I've been able to do most of it with a combination of a handful of UDF's, standard excel functions, and a CSV editor. One part still has me a little worried. So I've got cells that look like this:
Product Cost
RedWidg et100
BlueWid get200
I need to extract only the numeric portion of the cost field. I've got a UDF (which works, incidentally), I'm just not sure why. Since I'm converting variable types, I thought I would put it past the experts to make sure I'm doing this right:
[pre]
[/pre]
Product Cost
RedWidg et100
BlueWid get200
I need to extract only the numeric portion of the cost field. I've got a UDF (which works, incidentally), I'm just not sure why. Since I'm converting variable types, I thought I would put it past the experts to make sure I'm doing this right:
[pre]
Code:
Function ExtNum(target As Range)
Dim ticker As Integer
Dim testchar As String
Dim result As Integer
For ticker = 1 To Len(target)
testchar = Mid(target, ticker, 1)
If IsNumeric(testchar) = True Then
result = result & testchar
Else: result = result
End If
Next ticker
ExtNum = result
End Function