Here's a UDF fit for your purpose....
VB:
Option Explicit
Const MILES As Integer = 8
Const FURLONGS As Integer = 1
Const YARDS As Integer = 220
Const MILE_FLAG As String = "m"
Const FURLONG_FLAG As String = "f"
Const YARD_FLAG As String = "y"
Public Function convertToFurlongs(ByVal rngCell As Range) As Double
Dim intMiles As Integer: Dim intFurlongs As Integer: Dim intYards As Integer
Dim strTemp As String
Application.Volatile
strTemp = Trim(rngCell.Value)
If InStr(1, strTemp, MILE_FLAG, vbTextCompare) <> 0 Then
intMiles = getNumericValues(CInt(InStr(1, strTemp, MILE_FLAG, vbTextCompare) - 1), strTemp)
Else
intMiles = 0
End If
If InStr(1, strTemp, FURLONG_FLAG, vbTextCompare) <> 0 Then
intFurlongs = getNumericValues(CInt(InStr(1, strTemp, FURLONG_FLAG, vbTextCompare) - 1), strTemp)
Else
intFurlongs = 0
End If
If InStr(1, strTemp, YARD_FLAG, vbTextCompare) <> 0 Then
intYards = getNumericValues(CInt(InStr(1, strTemp, YARD_FLAG, vbTextCompare) - 1), strTemp)
Else
intYards = 0
End If
convertToFurlongs = (intMiles * MILES) + (intFurlongs / FURLONGS) + (intYards / YARDS)
End Function
Private Function getNumericValues(ByVal int_position As Integer, _
ByVal str_rng_value As String) As Integer
Dim strNumericValues As String
Do While int_position > 0
Select Case VBA.Mid(str_rng_value, int_position, 1)
Case 0 To 9
strNumericValues = strNumericValues + VBA.Mid(str_rng_value, int_position, 1)
Case Else
Exit Do
End Select
int_position = int_position - 1
Loop
getNumericValues = CInt(StrReverse(strNumericValues))
End Function
HTH
Craig
Bookmarks