I'm having some trouble looping through a variant array (8204 variable type). I'm am seeking input via an input box (type 8) and would like the user to be able to ctrl+ multiple disjointed ranges and cells. The problem that I am running into is that when I try and loop through those selected ranges it only picks up the first one.
Here's a working example of the issue:
Sub myarray()
MyAnswer = Application.InputBox("Pick a description cell(s) in spreadsheet for the link" _
& vbNewLine & "(Hold Ctrl to select multiple cells)", Type:=8)
' if its type 8204
If VarType(MyAnswer) = 8204 Then
MsgBox "Length of array: " & UBound(MyAnswer)
' loop through each element in the array
For Each vvalue In MyAnswer
MsgBox vvalue
Next
End If
End Sub
in the prompt type the following or select some ranges using ctrl+:
$A$12:$A$13,$B$4:$C$4,$D$4
for some reason I can only pick up the first range $A$12:$A$13 when I would like to loop through all elements in all the ranges/cells.
Any help is much appreciated. Thanks!