0

I want to be able to have a string consisting of numbers and letters in a cell. Then be able to split it so the text up to (and including) the last letter are in one cell, then the remaining numbers in the next cell.

For example, if the string is "sdgs214njkdsf123" then "sdgs214njkdsf" would be in one cell and "123" in the other.

antonioduarte
  • 655
  • 7
  • 19
  • Try to search for regex in VBA. Also, this question may help you at least for half problem: http://stackoverflow.com/questions/7239328/vba-how-to-find-numbers-from-string – antonioduarte Jul 13 '15 at 17:24

1 Answers1

1

Assuming the value is in A1:

Sub Splitter()
a = Range("A1").Value
For i = Len(a) To 1 Step -1
    If Not IsNumeric(Mid(a, i, 1)) Then Exit For
Next i
part1 = Left(a, i)
part2 = Right(a, Len(a) - i)
End Sub
Abe Gold
  • 2,307
  • 17
  • 29