View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.misc
Scott Scott is offline
external usenet poster
 
Posts: 87
Default Splitting column with text & numbers

There are probably simpler ways, but here's a possibility, using a user
defined function. Probably not the most elegant, but it should work.

Call with:
=SplitTextNum(A1,True) to get the text side of things
=SplitTextNum(A1,False) to get the number side of things

Function SplitTextNum(Part As String, TextPart As Boolean) As String
Dim x As Long
Dim s As Long
Dim i As Long

s = Len(Part)
x = s
For i = 1 To s
If "0" <= Mid(Part, i, 1) And Mid(Part, i, 1) <= "9" Then
x = i - 1
GoTo Finished
End If
Next i

Finished:
If TextPart Then
SplitTextNum = Left(Part, x)
Else
SplitTextNum = Right(Part, s - x)
End If
End Function

Scott

craezer wrote:
I am trying to split a column in a product catalog containing text and
numbers so I can further process the numbers. Each cell is consistent in that
the text is on the left side and numbers on the right. The problem is that
the quantity of words and numbers may vary from cell to cell. The closest
I've come is using space as a divider in "Text to Columns", but this results
in more work and concatenating because of the variable cell size.