You can use the Join
function:
Sub Test()
Dim var As Variant
'Populate a dummy vector array from a comma-separated list:
var = Split("Alpha,Beta,Gamma,Delta,Epsilon", ",")
'Display the contents of the array as delimited list, use the Carriage Return to delimit:
MsgBox Join(var, vbCR)
End Sub
The above does not ignore blanks. To ignore blanks, per your specific question, you can iterate over the array and test for blank values. I would do this in a Function
:
How do I put all non-blank elements of an array variable onto their own lines in a message box prompt
In your sub, just pass yankees
to this function, like:
MsgBox = GetMessageText(yankees)
Here is the function:
Function GetMessageText(var As Variant) As String
'Assumes a vector array
On Error GoTo EarlyExit
Dim sMsg As String
Dim v As Variant
For Each v In var
If Not v = vbNullString Then
sMsg = sMsg & v & vbCr
End If
Next
EarlyExit:
If Err.Number = 0 Then
GetMessageText = sMsg
Else:
GetMessageText = "invalid array"
End If
End Function