I'm working with a pair of scripts I found online and they almost work for my purposes but not quite. In the content I'm using it, I have a long string comprised of numbers and letters - accounting codes and accounts to be precise. The script that takes the letters does so admirably, but some of the account names have numbers in them so they are dropped. The other script that takes the numbers also removes any spaces between the numbers that are needed later.

So, for instance a column that contains something like:
'10 5200 302 2077 9999 211 3 TR 401 ABC DEF GHI'
with chars getChars script, I get 'TR ABC DEF GHI' - missing the 401
and the getNums script returns 105200302207799992113 - missing the spaces.

I've modified the numeric script to include spaces but then it pulls any number from anywhere and I'm only interested in the first portion of the string. So, while I get the correct 10 5200 302 2077 9999 211 3 , I also get the 401 from the account name.

I was hoping to keep this in functions so it will be easy for our finance team to run it themselves - too complicated and it will land on my desk every time it needs to be split - which I'd like to avoid.

While the test data and the sample file have 3 spaces between the numbers and letters, there's not guarantee that will continue in the future. The only thing I can think of for the numbers is to find the first letter in the string and somehow crawl backwards, find the last number and then get everything from the beginning to that point - but I'm sure there must be a better way.

My current iteration of the scripts are:

Function GetChars(target As Range) Dim MyStr As String, i As Integer MyStr = "" If Len(target.Value) = 0 Then GoTo GoExit For i = 1 To Len(target.Value) If Not IsNumeric(Mid(target, i, 1)) Then MyStr = MyStr & Mid(target, i, 1) Next iGoExit: GetChars = Trim(MyStr)End FunctionFunction GetNums(target As Range) Dim MyStr As String, i As Integer MyStr = "" If Len(target.Value) = 0 Then GoTo GoExit For i = 1 To Len(target.Value) If IsNumeric(Mid(target, i, 1)) Or Asc(Mid(target, i, 1)) = 32 Then MyStr = MyStr & Mid(target, i, 1) Next iGoExit: GetNums = MyStrEnd Function

Function GetChars(target As Range) Dim myStr As String, myChar As String, i As Integer If Len(target.Value) > 0 Then For i = 1 To Len(target.Value) myChar = Mid(target, i, 1) If Not IsNumeric(myChar) And myChar <> " " Then Exit For Next i myStr = Mid(target, i) End If GetChars = Trim(myStr)End FunctionFunction GetNums(target As Range) Dim myStr As String, myChar As String, i As Integer If Len(target.Value) > 0 Then For i = 1 To Len(target.Value) myChar = Mid(target, i, 1) If Not IsNumeric(myChar) And myChar <> " " Then Exit For Next i myStr = Mid(target, 1, i - 1) End If GetNums = Trim(myStr)End Function

Do you use a spreadsheet like Microsoft's Excel? Have you ever wanted to link out to a non excel file on your computer or network drive? This is the way I found to do it!

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents. The steps to find the Templates folder path are …

Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210 (2 * 3 * 5 * 7) or 2310 (2 * 3 * 5 * 7 * 11).
The larger templa…