View Single Post
 
Old 02-26-2013, 01:32 AM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Hi Tony,

The formula I posted is predicated on the data containg a + or - with commas occuring after them. Some of the data in your workbook lack either or both. Hence the errors. Here's a UDF that's perhaps more flexible & robust:
Code:
Function ParseIt(StrIn As Variant) As Variant
Dim i As Long, j As Long, k As Long
Dim StrTmp As String, StrOut As String
For i = 0 To UBound(Split(StrIn, ","))
  StrTmp = Split(Split(Split(StrIn, ",")(i), "+")(0), "-")(0)
  k = Len(StrTmp)
  For j = k To 1 Step -1
    If Not IsNumeric(Mid(StrTmp, j, 1)) Then
      StrTmp = Replace(StrTmp, Mid(StrTmp, j, 1), "")
    End If
  Next
  StrOut = StrOut & StrTmp & ","
Next
ParseIt = Left(StrOut, Len(StrOut) - 1)
End Function
To use it, add the function to an ordinary code module, then input a reference to it as a formula in the desired cell. For example, in J4, use =ParseIt(I4)
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote