Improve company productivity with a Business Account.Sign Up
Function DeleteEmpty(ByRef Arr As Variant) As Variant
If Not IsArray(Arr) Then Exit Function
Dim i As Long
Dim acount As Long
ReDim Preserve arrCopy(UBound(Arr))
acount = 0
For i = LBound(Arr) To UBound(Arr)
If Arr(i) & "" > "" Then
arrCopy(acount) = Arr(i)
acount = acount + 1
ReDim Preserve arrCopy(acount - 1)
DeleteEmpty = arrCopy
Dim ars(5) As String
ars(1) = "test"
ars(2) = ""
ars(3) = ""
ars(4) = "blah"
ars(5) = "blah"
MsgBox Join(DeleteEmpty(ars), ",")
Open in new window
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
Have a better answer? Share it in a comment.
Please enter a first name
Please enter a last name
Must be at least 4 characters long.
Join and Comment
From novice to tech pro — start learning today.
Premium members can enroll in this course at no extra cost.