Split string into numbers in Excel VBA

mathsbeauty

Board Regular
Joined
Apr 23, 2011
Messages
77
The string can be like "abc123(456 k789)". It is to be splitted in array like array[0]=123, array[1]=456, array[2]= 789. So the problem is to split array based on numbers.
 

steve the fish

Well-known Member
Joined
Oct 20, 2009
Messages
7,724
Office Version
365
Platform
Windows
Try this:

Code:
Dim s As String

s = "abc123(456 k789)"

With CreateObject("vbscript.regexp")
    .Pattern = "[^0-9]"
    .Global = True
    .IgnoreCase = True
    arr = Split(Application.Trim(.Replace(s, " ")), " ")
End With
 

Forum statistics

Threads
1,078,283
Messages
5,339,281
Members
399,291
Latest member
Bdbd55

Some videos you may like

This Week's Hot Topics

Top