I need your help to get URL from a specific cell.
For an example assume the below is the cell data I am referring to.
Microsoft Teams meeting
Join on your computer or mobile app
Click here to join the meeting https://teams.microsoft.com/l/meetup-join/19%3ameeting_OWEzN2JmZmEtOTVmMS00ZDc4LThlNzQtNjQyNWM0ZjllODIx%40thread.v2/0?context=%7c%22Tid%22%3a%227a916015-20ae-4ad1-9170-eafd915e9272%22%2c%24Oid%22%3a%22b8ed972c-91b4-4fe1-a5d5-1410ea30a159%22%7d
Learn More https://aka.ms/JoinTeamsMeeting | Meeting options https://teams.microsoft.com/meetingOptions/?organizerId=b8ed972c-79b4-4fe1-a5d5-1410ea30a159&tenantId=7a916015-20ae-4ad1-9170-eefd915e9272&threadId=19_meeting_OWEzN2JmZmEtOTVmMS00ZDc4LThlNzQtNjQyNWM0ZjllODIx#thread.v2&messageId=0&language=en-US
So from above cell text i want to copy the first URL to another cell.
Request your guidance.
Please, try the next function:
Function extractURLs(strCell As String) As Variant
Dim frst As Long, lst As Long, arr, k As Long, sp As Long
Dim pos As Long, URLNo As Long, i As Long
'count existing number if URLs:
Do
pos = InStr(pos + 1, strCell, "https:")
If pos > 0 Then
URLNo = URLNo + 1
End If
Loop While pos > 0
If URLNo = 0 Then extractURLs = Array("Error"): Exit Function 'in case of no URL being found
ReDim arr(URLNo - 1) 'ReDim the array to keep the found URLs
For i = 1 To URLNo 'loop between the above occurrences found number
frst = InStr(frst + 1, strCell, "https:") 'determine the first occurrence for https: string
lst = InStr(frst, strCell, vbLf) 'determine the last occurrence (starting from frst) for end of line
If lst > 0 Then 'if the string is found:
sp = InStr(Mid(strCell, frst, lst - frst), " ") 'determine if a space exists in the string between first and last
If sp > 0 Then 'if it exists:
arr(k) = Mid(strCell, frst, sp): k = k + 1 'it returns the string up to the first space
Else
arr(k) = Mid(strCell, frst, lst - frst): k = k + 1 'if returns the string up to the end of line
End If
End If
Next i
extractURLs = arr 'return the array content
End Function
It can be tested like in such a code:
Sub testExtractURLs()
Dim strTest As String, arr, i As Long
strTest = ActiveCell.value
arr = extractURLs(strTest)
If UBound(arr) = 0 Then
If arr(0) = "Error" Then
MsgBox "No any URL could be found..."
Else
Debug.Print arr(0)
End If
Else
For i = 0 To UBound(arr)
Debug.Print arr(i)
Next i
End If
End Sub
Please, test it and send some feedback
Related
I have a Text file which looks like this
'52132205501000655
JAMES BOND
CC34TYU ,'006039869 , 350000, -358300.51, 0,19-04-2022, 8300.51, 0,001A
1 DAY < ACCOUNT OVERDRAWN <= 90 DAYS
'0362205501000655
WILSON JOE
CC34ZYU ,'006039869 , 550000, -358300.51, 0,19-04-2022, 8300.51, 0,001A
1 DAY < ACCOUNT OVERDRAWN <= 60DAYS
'0552205501000955
QUEEN VELVET
CDDFTYU ,'006039869 , 350000, -358300.51, 0,19-04-2022, 8300.51, 0,001A
1 DAY < ACCOUNT OVERDRAWN <= 50DAYS
I want output in a spreadsheet like MS Excel like this
'52132205501000655 JAMES BOND CC34TYU '006039869 350000 -358300.51 0 19-04-2022 8300.51 1 DAY < ACCOUNT OVERDRAWN <= 90 DAYS
which is to say that until my program encounters a blank line it should read all the values and if it contains a delimiter(, in my case) split them and put them in consecutive rows. My code reads as
Sub ReadTextFileWithSeparators()
Dim StrLine As String
Dim FSO As New FileSystemObject
Dim TSO As Object
Dim StrLineElements As Variant
Dim RowIndex As Long
Dim ColIndex As Long
Dim Delimiter As String
Set FSO = CreateObject("Scripting.FileSystemObject")
Set TSO = FSO.OpenTextFile("C:\temp\sample.txt")
Delimiter = ","
RowIndex = 1
Do While TSO.AtEndOfStream = False
StrLine = TSO.ReadLine
Do While StrLine <> vbNullString
StrLine = TSO.ReadLine
StrLineElements = Split(StrLine, Delimiter)
For ColIndex = LBound(StrLineElements) To UBound(StrLineElements)
Cells(RowIndex, ColIndex + 1).Value = StrLineElements(ColIndex)
Next ColIndex
Loop
RowIndex = RowIndex + 1
Loop
TSO.Close
Set TSO = Nothing
Set FSO = Nothing
End Sub
However i dont seem to get the desired output. Where i am doing wrong
Please, test the next code. It uses arrays and should be very fast, processing only in memory. It assumes that all text file contains groups of four lines, separate by an empty line. It will return in separate cells for each file line. The processing result will be dropped in the active sheet, starting from "A1" (header included):
Sub ReadTextFile()
Dim textFileName As String, arrTxt, arrRet, arr4Lines, arrL, arrFin, colNo As Long
Dim i As Long, j As Long, L As Long, k As Long, kk As Long, n As Long, sep As String
textFileName = "C:\temp\sample.txt"
sep = vbCrLf 'ito be changed with vbCr or vbLf if the text file will not be split on the chosen line separator
arrTxt = Split(CreateObject("Scripting.FileSystemObject").OpenTextFile(textFileName, 1).ReadAll, sep)
If UBound(arrTxt) = 0 Then MsgBox "Strange line separator..." & vbCrLf & _
"Try replacing it with 'vbCr' or 'vbLf 'and run the code again.", vbInformation, _
"Separator change needed": Exit Sub
colNo = UBound(Split(arrTxt(2), ",")) + 4 'the number of necessary columns in the final array (in a consistent txt file)
ReDim arrFin(1 To UBound(arrTxt) + 5, 1 To colNo): kk = 1 'the final array to drop its content in the sheet
For i = 0 To UBound(arrTxt) Step 5
ReDim arr4Lines(UBound(Split(arrTxt(2), ",")) * 4) 'to be sure that it is enough space to place all split elements...
For j = 0 To 3
If left(arrTxt(i + j), 1) = "=" Or arrTxt(i + j) = "" Then Exit For 'for the ending file part
arrL = Split(arrTxt(i + j), ",")
For L = 0 To UBound(arrL)
arr4Lines(k) = WorksheetFunction.Trim(arrL(L)): k = k + 1 'place in the array all the line elements (separated by comma)
Next L
Next j
If k > 0 Then
ReDim Preserve arr4Lines(k - 1) 'keep only the loaded array elements
For n = 0 To k - 1
arrFin(kk, n + 1) = arr4Lines(n) 'place the elements in the final array
Next n
kk = kk + 1 'increment the final array row
End If
Erase arr4Lines: k = 0
Next i
'drop the processed array content at once and format a little the respective range:
With ActiveSheet.Range("A2").Resize(kk - 1, colNo)
.value = arrFin
.rows(1).Offset(-1) = Array("Column1", "Column2", "Column3", "Column4", "Column5", "Column6", _
"Column7", "Column8", "Column9", "Column10", "Column11", "Column12") 'place here the necessary headers
.EntireColumn.AutoFit
End With
End Sub
Using a Macro or Formula, is there a way to achieve the result of the following formula of Office 365?
=FILTER(B:B,A:A = "x")
What it does is get all the values from Column B if Column A on the same row has a value of x.
My PC has office 365 but the one I'm working with only has Office Pro Plus 2019. I had to use my pc when I needed the function and I'm getting tired of it, maybe it can be done on Office Pro Plus 2019 too using a formula or a macro?
Use:
=IFERROR(INDEX($B$1:$B$100,AGGREGATE(15,7,ROW($A$1:$A$100)/($A$1:$A$100="x"),ROW($ZZ1))),"")
Note the use of a set range and not full columns. That is done on purpose, This being an array formula it will do a lot of calculations each cell it is placed. Limiting the range to the data set will speed it up.
Put this in the first cell of the output and copy down till blanks are returned.
I had some spare time and I am recently interested in User defined functions so I decided to make my own version of what I imagine this would be. I'm prefacing this by saying its not good and is excessively long but it works!
Function JOINIF(ByRef IfRange As Range, ByVal Criteria As String, Optional JoinRange As Range, Optional Delimeter As String = ",") As String
'IfRange is the range that will be evaluated by the Criteria
'Criteria is a logical test that can be applied to a cell value.
'Examples of Criteria: "=Steve", ">100", "<>Toronto", "<=-1"
'JoinRange is the range of values that will be concatenated if the corresponding -
'IfRange cell meets the criteria. JoinRange can be left blank if the values to be -
'concatenated are the IfRange values.
'Delimeter is the string that will seperate the concatenated values.
'Default delimeter is a comma.
Dim IfArr() As Variant, JoinArr() As Variant, OutputArr() As String
Dim IfArrDim As Integer, JoinArrDim As Integer
Dim JCount As Long, LoopEnd(1 To 2) As Long
Dim MeetsCriteria As Boolean, Expression As String
Dim i As Long, j As Long
'PARSING THE CRITERIA
Dim Regex As Object
Set Regex = CreateObject("VBScript.RegExp")
Regex.Pattern = "[=<>]+"
'Looking for comparison operators
Dim Matches As Object
Set Matches = Regex.Execute(Criteria)
If Matches.Count = 0 Then
'If no operators found, assume default "Equal to"
If Not IsNumeric(Criteria) Then
'Add quotation marks to allow string comparisons
Criteria = "=""" & Criteria & """"
End If
Else
If Not IsNumeric(Replace(Criteria, Matches(0), "")) Then
Criteria = Matches(0) & """" & Replace(Criteria, Matches(0), "") & """"
End If
'Add quotation marks to allow string comparisons
End If
'Trim IfRange to UsedRange
Set IfRange = Intersect(IfRange, IfRange.Parent.UsedRange)
'Default option for optional JoinRange input
If JoinRange Is Nothing Then
Set JoinRange = IfRange
Else
Set JoinRange = Intersect(JoinRange, JoinRange.Parent.UsedRange)
End If
'DIMENSIONS
'Filling the arrays
If IfRange.Cells.Count > 1 Then
IfArr = IfRange.Value
IfArrDim = Dimensions(IfArr)
Else
ReDim IfArr(1 To 1)
IfArr(1) = IfRange.Value
IfArrDim = 1
End If
If JoinRange.Cells.Count > 1 Then
JoinArr = JoinRange.Value
JoinArrDim = Dimensions(JoinArr)
Else
ReDim JoinArr(1 To 1)
JoinArr(1) = JoinRange.Value
JoinArrDim = 1
End If
'Initialize the Output array to the smaller of the two input arrays.
ReDim OutputArr(IIf(IfRange.Cells.Count < JoinRange.Cells.Count, IfRange.Cells.Count - 1, JoinRange.Cells.Count - 1))
'DEFINING THE LOOP PARAMETERS
'Loop ends on the smaller of the two arrays
If UBound(IfArr) > UBound(JoinArr) Then
LoopEnd(1) = UBound(JoinArr)
Else
LoopEnd(1) = UBound(IfArr)
End If
If IfArrDim = 2 Or JoinArrDim = 2 Then
If Not (IfArrDim = 2 And JoinArrDim = 2) Then
'mismatched dimensions
LoopEnd(2) = 1
ElseIf UBound(IfArr, 2) > UBound(JoinArr, 2) Then
LoopEnd(2) = UBound(JoinArr, 2)
Else
LoopEnd(2) = UBound(IfArr, 2)
End If
End If
'START LOOP
If IfArrDim = 1 Then
For i = 1 To LoopEnd(1)
If IsNumeric(IfArr(i)) And IfArr(i) <> "" Then
Expression = IfArr(i) & Criteria
Else
'Add quotation marks to allow string comparisons
Expression = """" & IfArr(i) & """" & Criteria
End If
MeetsCriteria = Application.Evaluate(Expression)
If MeetsCriteria Then
If JoinArrDim = 1 Then
OutputArr(JCount) = CStr(JoinArr(i))
Else
OutputArr(JCount) = CStr(JoinArr(i, 1))
End If
JCount = JCount + 1
End If
Next i
Else
For i = 1 To LoopEnd(1)
For j = 1 To LoopEnd(2)
If IsNumeric(IfArr(i, j)) And IfArr(i, j) <> "" Then
Expression = IfArr(i, j) & Criteria
Else
'Add quotation marks to allow string comparisons
Expression = """" & IfArr(i, j) & """" & Criteria
End If
MeetsCriteria = Application.Evaluate(Expression)
If MeetsCriteria Then
If JoinArrDim = 1 Then
OutputArr(JCount) = CStr(JoinArr(i))
Else
OutputArr(JCount) = CStr(JoinArr(i, j))
End If
JCount = JCount + 1
End If
Next j
Next i
End If
'END LOOP
ReDim Preserve OutputArr(JCount + 1 * (JCount > 0))
JOINIF = Join(OutputArr, Delimeter)
End Function
Private Function Dimensions(var As Variant) As Long
'Credit goes to the great Chip Pearson, chip#cpearson.com, www.cpearson.com
On Error GoTo Err
Dim i As Long, tmp As Long
While True
i = i + 1
tmp = UBound(var, i)
Wend
Err:
Dimensions = i - 1
End Function
Examples of it in use:
Seperate IfRange and JoinRange
IfRange as the JoinRange
You might try the following udf (example call: FILTER2(A1:A100,B1:B100)) consisting of the following tricky steps:
a) Evaluate the general condition (=If(A1:A100="x",Row(A1:A100),"?") as tabular Excel formula and assign all valid row numbers to array x (marking the rest by "?" strings),
b) Filter out all "?" elements
c) Apply x upon the data column benefitting from the advanced restructuring features of Application.Index()
Public Function Filter2(rng1 As Range, rng2 As Variant, Optional ByVal FilterID As String = "x")
Dim a As String: a = rng1.Address(False, False, External:=True)
'a) get all valid row numbers (rng1)
Dim myformula As String: myformula = "if(" & a & "=""" & FilterID & """,row(" & a & "),""?"")"
Dim x: x = Application.Transpose(Evaluate(myformula))
'b) filter out invalid "?" elements
x = VBA.Filter(x, "?", False)
'c) apply x upon data column (rng2)
If UBound(x) > -1 Then Filter2 = Application.Index(rng2, Application.Transpose(x), 1)
End Function
Note that function calls before versions 2019/MS 365 need to be entered as array formula (Ctrl+Shift+Enter).
The function assumes one-column (range) arguments.
Edit due to comment as of 2022-06-08
The whole example is based on the actual row numbers starting in the first row (OP ranges refer to A:A,B:B. If you want to allow ranges to start at any row, you'd need to change the myFormula definition in section a) by correcting the row indices by subtracting possible offsets (row number + 1 - first row):
Dim myFormula As String
myFormula = "if(" & a & "=""" & FilterID & """,row(" & a & ")+1 -" & rng1.Row & ",""?"")"
Try this UDF for the Filter Function:
Function FILTER_HA(Where, Criteria, Optional If_Empty) As Variant
Dim Data, Result
Dim i As Long, j As Long, k As Long
'Create space for the output (same size as input cells)
With Application.Caller
i = .Rows.Count
j = .Columns.Count
End With
'Clear
ReDim Result(1 To i, 1 To j)
For i = 1 To UBound(Result)
For j = 1 To UBound(Result, 2)
Result(i, j) = ""
Next
Next
'Count the rows to show
For i = 1 To UBound(Criteria)
If Criteria(i, 1) Then j = j + 1
Next
'Empty?
If j < 1 Then
If IsMissing(If_Empty) Then
Result(1, 1) = CVErr(xlErrNull)
Else
Result(1, 1) = If_Empty
End If
GoTo ExitPoint
End If
'Get all data
Data = Where.Value
'Copy the rows to show
For i = 1 To UBound(Data)
If Criteria(i, 1) Then
k = k + 1
For j = 1 To UBound(Data, 2)
Result(k, j) = Data(i, j)
Next
End If
Next
'Return the result
ExitPoint:
FILTER_HA = Result
End Function
I have the following Excel sheet which has random number combinations build using numbers from 2 to 50 in set of 3, 2 and 1 in Column A.
I am trying to build whole possible combinations between Column A elements such that the obtained combination doesn't have any repeating numbers in them and contains all the number from 2 to 50.
My current code starts from A2 and builds only a single combination set. It doesn't evaluate other possible combinations with starting element as in A2, it then goes to A3 and then builds only one combination set using A3. This step continues for A4,A5...
This is my current code.
Private Sub RP()
Dim lRowCount As Long
Dim temp As String, s As String
Dim arrLength As Long
Dim hasElement As Boolean
Dim plans() As String, currentPlan() As String
Dim locationCount As Long
Dim currentRoutes As String
Dim line As Long
Worksheets("Sheet1").Activate
Application.ActiveSheet.UsedRange
lRowCount = ActiveSheet.UsedRange.Rows.Count
locationCount = -1
line = 2
Debug.Print ("*********")
For K = 2 To lRowCount - 1
currentRoutes = ""
For i = K To lRowCount
s = ActiveSheet.Cells(i, 1)
Do
temp = s
s = Replace(s, " ", "")
Loop Until temp = s
currentPlan = Split(Trim(s), ",")
arrLength = UBound(currentPlan) - LBound(currentPlan) + 1
hasElement = False
If Len(Join(plans)) > 0 Then
For j = 0 To arrLength - 1
pos = Application.Match(currentPlan(j), plans, False)
If Not IsError(pos) Then
hasElement = True
Exit For
End If
Next j
End If
If Not hasElement Then
currentRoutes = currentRoutes & (Join(currentPlan, ",")) & " "
If Len(Join(plans)) > 0 Then
plans = Split(Join(plans, ",") & "," & Join(currentPlan, ","), ",")
Else
plans = currentPlan
End If
End If
Next i
If locationCount < 0 Then
locationCount = UBound(plans) - LBound(plans) + 1
End If
If (UBound(plans) - LBound(plans) + 1) < locationCount Then
Debug.Print ("Invalid selection")
Else
Debug.Print (Trim(currentRoutes))
Worksheets("Sheet1").Cells(line, 11) = currentRoutes
line = line + 1
End If
Erase plans
Debug.Print ("*********")
Next K
End Sub
I'm trying to write code that extracts X consecutive numbers from text.
For example, if I want to extract 5 consecutive numbers in my text:
Cell A1: dsuad28d2hr 22222222 11111 d33d11103
Cell B2: 11111 (wanted)
I could make it work for texts with only 5 numbers but the problem is if my text contains other consecutive numbers higher than 5.
Sub ExtractNum2()
Dim Caract() As String
Dim i As Integer
Dim j As Integer
Dim z As Integer
Dim cont As Integer
Dim goal As Integer
Dim Protocolo() As String
Dim cel As String
Dim lin As Long
lin = Range("A1", Range("A1").End(xlDown)).Rows.Count 'Repeat for each line
For z = 1 To lin
cel = Cells(z, 1)
ReDim Caract(Len(cel))
ReDim Protocolo(Len(cel))
cont = 0
For i = 1 To Len(cel)
Caract(i) = Left(Mid(cel, i), 1)
If IsNumeric(Caract(i)) Then 'Character check
cont = cont + 1
Protocolo(cont) = Caract(i)
'If Not IsNumeric(Caract(6)) And cont = 5 Then**
If cont = 5 '
Dim msg As String
For j = 1 To 5
msg = msg & Protocolo(j)
Next j
Cells(z, 2) = msg 'fills column B
msg = ""
End If
Else
cont = 0
End If
Next i
Next z 'end repeat
End Sub
I'm trying to use:
If Not IsNumeric(Caract(6)) And cont = 5 Then
But it is not working, my output is: B2: 22222 but I want 11111.
What am I missing?
EDIT
Sorry i wasnt clear. I want to extract X numbers with 6>x>4 (x=5). I dont want 22222 since it has 8 consecutive numbers and 11111 has 5 in my example.
UDF:
Function GetNum(cell)
With CreateObject("VBScript.RegExp")
.Pattern = "\b(\d{5})\b"
With .Execute(cell)
If .Count > 0 Then GetNum = .Item(0).SubMatches(0)
End With
End With
End Function
UPDATE:
If you want to return error (say, #N/A) instead of callee's default data type, you could write the following:
Function GetNum(cell)
With CreateObject("VBScript.RegExp")
.Pattern = "\b(\d{5})\b"
With .Execute(cell)
If .Count > 0 Then
GetNum = .Item(0).SubMatches(0)
Else
GetNum = CVErr(xlErrNA)
End If
End With
End With
End Function
I tried this with a Cell containing "Yjuj 525211111x5333332s5" to test whether 2 consecutive 5 characters get catch, and it worked great.
Sub Macro_Find_Five()
Dim str As String
Dim tmp As String
Dim cntr As Integer
Dim result As String
str = Sheet1.Cells(1, 1).Value
tmp = ""
cntr = 1
col = 2
result = ""
'For Loop for tracing each charater
For i = 1 To Len(str)
'Ignore first starting character
If i > 1 Then
'If the last character matches current character then
'enter the if condition
If tmp = Mid(str, i, 1) Then
'concatenate current character to a result variable
result = result + Mid(str, i, 1)
'increment the counter
cntr = cntr + 1
Else
'if the previous character does not match
'reset the cntr to 1
cntr = 1
'as well initialize the result string to "" (blank)
result = ""
End If
End If
'if cntr matches 5 i.e. 5 characters traced enter if condition
If cntr = 5 Then
'adding to next column the result found 5 characters same
Sheet1.Cells(1, col).Value = result
'increment the col (so next time it saves in next column)
col = col + 1
'initializing the variables for new search
cntr = 1
tmp = ""
result = ""
End If
'stores the last character
tmp = Mid(str, i, 1)
'if first character match concatenate.
If cntr = 1 Then
result = result + Mid(str, i, 1)
End If
Next i
End Sub
I am trying to split the contents of a column into various columns. The column has content that looks like this:
3-BW16569*AW34586*AW34587
3- LVA18140 & LVA19222
3-LVA22841
3- JDSC RELOAD
3 - LV1 TO JDSC 6/21
3- LVU21690
3-LVA19520*LVU21739
3- R241974/R241974
The column is not in a particular format but always has different symbols between the elements to separate them. Can a macro code help with this or a excel function. Thank you!
All thanks to alainbryden for the function SplitMultiDelims() . . don't change it, foo() may help you through in how to use it in your problem...
Sub foo()
Dim ws As Worksheet
Dim sizeArr, index As Integer
Dim Arr() As String
Set ws = ThisWorkbook.Worksheets("Sheet1")
Dim str As String
Dim dilimiters As String
Dim str1 As String
dilimiters = " -*" ' provide all of them
str = "3-BW16569*AW34586*AW34587" ' read the string
'str = ws.Cells(1, 1).Value
Debug.Print str
Arr = SplitMultiDelims(str, dilimiters) ' delimit
sizeArr = UBound(Arr) ' get no of different strings you have
For index = 0 To sizeArr Step 1
str1 = Arr(index) ' get the string
Debug.Print str1
' now paste where evere you want
Next
End Sub
Function SplitMultiDelims(ByRef Text As String, ByRef DelimChars As String, _
Optional ByVal IgnoreConsecutiveDelimiters As Boolean = False, _
Optional ByVal Limit As Long = -1) As String()
Dim ElemStart As Long, N As Long, M As Long, Elements As Long
Dim lDelims As Long, lText As Long
Dim Arr() As String
lText = Len(Text)
lDelims = Len(DelimChars)
If lDelims = 0 Or lText = 0 Or Limit = 1 Then
ReDim Arr(0 To 0)
Arr(0) = Text
SplitMultiDelims = Arr
Exit Function
End If
ReDim Arr(0 To IIf(Limit = -1, lText - 1, Limit))
Elements = 0: ElemStart = 1
For N = 1 To lText
If InStr(DelimChars, Mid(Text, N, 1)) Then
Arr(Elements) = Mid(Text, ElemStart, N - ElemStart)
If IgnoreConsecutiveDelimiters Then
If Len(Arr(Elements)) > 0 Then Elements = Elements + 1
Else
Elements = Elements + 1
End If
ElemStart = N + 1
If Elements + 1 = Limit Then Exit For
End If
Next N
'Get the last token terminated by the end of the string into the array
If ElemStart <= lText Then Arr(Elements) = Mid(Text, ElemStart)
'Since the end of string counts as the terminating delimiter, if the last character
'was also a delimiter, we treat the two as consecutive, and so ignore the last elemnent
If IgnoreConsecutiveDelimiters Then If Len(Arr(Elements)) = 0 Then Elements = Elements - 1
ReDim Preserve Arr(0 To Elements) 'Chop off unused array elements
SplitMultiDelims = Arr
End Function