Several Multiselect Listbox to same row

feildannie22

New Member
Joined
Jun 26, 2012
Messages
3
I have several multiselect listboxes on a userform. After the user makes their selections, I would like for the data to be transfered to the same row on the spreadsheet (no matter if there is an empty row above it). I can get this to happen with textboxes and single select listboxes, but not with the multiselect. These are skipped completely.

Here is what I have so far.
Code:
Dim Rab As Long
 
    With Workbooks("NEW MAG DATABASE TEST ONLY 444.xlsm").Worksheets("MAGAZINE DATA")
         Rab = .Cells(.Rows.Count, 1).End(xlUp).Row + 1
         .Cells(Rab, 1).Value = Me.BuildingNumber1.Value
         .Cells(Rab, 2).Value = Me.TextBox1.Text
         .Cells(Rab, 3).Value = Me.Inspector1.Value
         .Cells(Rab, 4).Value = Me.MagType1.Value
         .Cells(Rab, 5).Value = Me.LockType1.Value
         .Cells(Rab, 6).Value = Me.HaspType1.Value
         
         End With
"Inspector1" is the multiselect listbox. Any assistance at all would be greatly appreciated.
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
You would need something like below to place the multi selected items in a row.
Code:
[COLOR="Navy"]Sub[/COLOR] MG26Jun05
[COLOR="Navy"]Dim[/COLOR] c [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Integer[/COLOR]
[COLOR="Navy"]Dim[/COLOR] n [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Integer[/COLOR]
[COLOR="Navy"]Dim[/COLOR] ray()
c = 0
[COLOR="Navy"]With[/COLOR] Inspector1
 [COLOR="Navy"]For[/COLOR] n = 0 To .ListCount - 1
    [COLOR="Navy"]If[/COLOR] .Selected(n) [COLOR="Navy"]Then[/COLOR]
        ReDim Preserve ray(c)
        ray(c) = .List(n)
        c = c + 1
    [COLOR="Navy"]End[/COLOR] If
  [COLOR="Navy"]Next[/COLOR] n
[COLOR="Navy"]End[/COLOR] With
Cells(1, "C").Resize(, c) = ray
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]Sub[/COLOR]
Regards Mick
 
Upvote 0
Have you tried the code by itself.???
The code is just a trial that returns the values to Row (1) starting "C1".
You need to set the Listbox List fillrange to some range of data and the MultiSelect Property To fmMultiSelectMulti.
If you running the code from a Basic module you will need to prefix the following line with "Activesheet"
Code:
With Activesheet.Inspector1
Mick
 
Last edited:
Upvote 0

Forum statistics

Threads
1,203,460
Messages
6,055,556
Members
444,797
Latest member
18ecooley

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