Transferring Array into a Cell

TheShaunMichael

Board Regular
Joined
Oct 24, 2009
Messages
57
Have a multi-select enabled list box on a userform. Would like to transfer a list of the selected values to Range("R2"). I've got all of the selected values in an array but am struggling with putting the array values into a cell.

For X = 0 To Me.lbSourceLanguage.ListCount - 1
If Me.lbSourceLanguage.Selected(X) Then
ArrItem = ArrItem + 1
ReDim Preserve arr(ArrItem)
arr(ArrItem) = Me.lbSourceLanguage.List(X)
End If
Next X

Where do I go from here?

Have tried:
.Cells(2, 18).value = arr
.Range("R2").value = arr

and other similar strings..
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
You can't put an array in a cell, but you can put a string
Code:
ArrItem = 0

With Me.lbSourceLanguage
    ReDim arr (1 to .ListCount)

    For X = 0 to .ListCount - 1
        If .Selected(X) Then
            ArrItem = ArrItem + 1
            arr(ArrItem) = .List(x)
        End If 
    Next X
End With

Redim Preserve arr(1 to ArrItem)
Range("A1").Value = Join(arr, ", ")
 
Upvote 0
Awesome! Thank you so much.

Just so I understand - why can't an array go into a cell? Other similar situations you can think of?
 
Upvote 0

Forum statistics

Threads
1,224,517
Messages
6,179,233
Members
452,898
Latest member
Capolavoro009

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top