I have a bunch of cells with string like this: WFM 1601
And this: WFM 2231, WFM 2402
And this too: Campaign 1680, 2402, 2784
I used code, below, to split the string in a single cell into multiple columns (max of 3).
Dim Rng As Range
Dim WorkRng As Range
On Error Resume Next
lRow = Range("U" & Rows.Count).End(xlUp).Row
Set MyRows = Range("U19:U" & lRow)
For Each cell In MyRows
splitVals = Split(cell.Value, ",")
totalVals = UBound(splitVals)
Range(Cells(cell.Row, ActiveCell.Column + 1), Cells(cell.Row, ActiveCell.Column + 1 + totalVals)).Value = splitVals
Next
Now, I'm trying to figure out a way to get rid of all NON numeric characters and leave only numbers. Then, concatenate these numbers, which are all IDs for processes in a SharePoint site that I work with, so I want to place the URL for each number, at the end of a static string, and next to the number that was just split into separate columns.
Here is a screen shot.
I have Column U, and I want to generate Column V to Column AA.
I can extract only numbers using the function below.
Function GetNums(target As Range)
Dim MyStr As String, i As Integer
MyStr = ""
If Len(target.Value) = 0 Then GoTo GoExit
If target.Value = "None" Then GoTo GoNone
For i = 1 To Len(target.Value)
If IsNumeric(Mid(target, i, 1)) Then MyStr = MyStr & Mid(target, i, 1)
Next i
GoTo GoExit
GoNone:
GetNums = "None"
Exit Function
GoExit:
GetNums = MyStr
End Function
However, this won't meet the requirement as it checks all characters in a cell, and just turns this: WFM 2231, WFM 2402 . . . Into this: 22312402 I really need some way to distinguish the two IDs: 2231 2402