Select Userform Listbox data and paste to selected cell variable range

Easy59

New Member
Joined
Jan 11, 2020
Messages
4
Office Version
  1. 2019
Platform
  1. Windows
I have a Userform List box where I can select values (in this case Date) with a check box and a button that copies the values to a cell.
I can select as many values as I like. Unfortunaely, all the values are populated into 1 cell

What I intend, is to select no more than 3 values and paste to a range of cells in a column

So,
first value would be pasted in to cells A5,A10, A15, ....,A35
and if a Second value selected, then would be pasted into cells A6, a11, A16, ....,A36
and if a third value selected, then would be pasted into A7, A12, a17, ..., A37.

Can I do this from a Userform List box. If so, how? If not, the best way forward.
Many thanks for any assistance.

I have tried to download a copy of the work sheet, but 'The uploaded file does not have an allowed extension' message appears
Easy59
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
Here is the code that I am using to move values from list box to selected cell.

Private Sub CommandButton2_Click()
Dim x As Long
For x = 0 To ListBox1.ListCount - 1
If ListBox1.Selected(x) = True Then
If Range("a5").Value = "" Then
Range("a5").Value = ListBox1.List(x)
Else
Range("a5").Value = Range("a5").Value & ", " & ListBox1.List(x)
End If
End If
Next x
Unload Me
End Sub

Is it possible to attach a .xls file?
Many thanks
Easy59
 
Upvote 0
Book1
ABCDEFGHIJKLMNOPQRSTUVWXYZAAABACADAEAFAGAHAIAJAK
1DatesTime
2 CARGO OIL ACROSS FREE WATER03/04/201610:00
3Time1 Port1 Centre1 Stbd1 X04/04/201611:00
4ULIFWaterOilVol%fullSampleTEMPULIFWaterOilVol%fullSampleTEMPULIFWaterOilVol%fullSampleTEMP05/04/201612:00
510:00#N/A#N/A#N/A#N/A#N/A1%#N/A#N/A#N/A#N/A#N/A#N/A90%#N/A#N/A#N/A#N/A#N/A#N/A1%#N/A#N/A#N/A06/04/201613:00
60000007/04/201614:00
70000008/04/2016
82 Port2 Centre2 Stbd2X
9ULIFWaterOilVol%fullSampleTEMPULIFWaterOilVol%fullSampleTEMPULIFWaterOilVol%fullSampleTEMP 
1004/04/20165:00#N/A#N/A#N/A#N/A581790%26.0#N/A#N/A#N/A60668931.3#N/A#N/A#N/A#N/A581990%24.5#N/A#N/A 
1100000 
1200000 
133 Port3 Centre3 Stbd3X 
14ULIFWaterOilVol%fullSampleTEMPULIFWaterOilVol%fullSampleTEMPULIFWaterOilVol%fullSampleTEMP 
1523:30#N/A#N/A#N/A#N/A151%29.0#N/A#N/A#N/A#N/A91%31.2#N/A#N/A#N/A#N/A151%28.0#N/A#N/A 
1600000 
1700000 
184 Port4 Centre4 Stbd4X 
19ULIFWaterOilVol%fullSampleTEMPULIFWaterOilVol%fullSampleTEMPULIFWaterOilVol%fullSampleTEMP 
204:30#N/A#N/A#N/A#N/A2213%35.0#N/A#N/A#N/A#N/A614391%25.3#N/A#N/A#N/A#N/A1563%27.0#N/A#N/A 
2100000 
2200000 
235 Port5 Centre5 Stbd5X 
24ULIFWaterOilVol%fullSampleTEMPULIFWaterOilVol%fullSampleTEMPULIFWaterOilVol%fullSampleTEMP 
2523:30#N/A#N/A#N/A#N/A360356%26.3#N/A#N/A#N/A#N/A505675%38.3#N/A#N/A#N/A#N/A357755%26.5#N/A#N/A 
2600000 
2700000 
286 Port6 Centre6 Stbd6X 
29ULIFWaterOilVol%fullSampleTEMPULIFWaterOilVol%fullSampleTEMPULIFWaterOilVol%fullSampleTEMP 
305:30#N/A#N/A#N/A#N/A189532.1#N/A#N/A#N/A#N/A313292%0.100%34.4#N/A#N/A#N/A#N/A185058%32.6#N/A#N/A 
310000 
3200000 
33Port SlopStbd SlopSLOPS 
34ULIFWATERVOLOIL%fullTEMPULIFWATERVOLOIL%fullTEMP 
3523:30#N/A#N/A#N/A682#N/A40%37.920/11/201923:30#N/A#N/A#N/A719#N/A42%30.4#N/A#N/A 
3600 
37000 
DailySheet
 
Upvote 0
I am modifying my request.

I have a Userform List box where I can select values (in this case Date) with a check box and a button that adds the select dates to a cell.
I can select as many values as I like. Unfortunaely, all the dates are populated into 1 cell

What I intend, is to select no more than 3 dates and paste to a range of cells in a column ( Namely A5:A7)

How do I modify the above code to carry out this task.

Can I do this from a Userform List box. If so, how? If not, the best way forward.

If there is someone out there who could assist, I would be very greatful
Many thanks for any assistance.
 
Upvote 0

Forum statistics

Threads
1,215,044
Messages
6,122,827
Members
449,096
Latest member
Erald

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