Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,814
Default Multi select Listbox

I have a userform with listbox set to multi select which gets list from a
worksheet. I want to be able to select a selection from the list and that
selection to go into another worksheet. Please can anyone help with this?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Multi select Listbox

Option Explicit
Private Sub CommandButton1_Click()
Dim DestCell As Range
Dim iCtr As Long

With Worksheets("sheet1")
Set DestCell = .Range("A1")
End With

With Me.ListBox1
DestCell.Resize(.ListCount, 1).ClearContents

For iCtr = 0 To .ListCount - 1
If .Selected(iCtr) Then
DestCell.Value = .List(iCtr)
Set DestCell = DestCell.Offset(1, 0)
End If
Next iCtr
End With
End Sub
Private Sub UserForm_Initialize()
With Me.ListBox1
.MultiSelect = fmMultiSelectMulti
.AddItem "a"
.AddItem "b"
.AddItem "c"
.AddItem "d"
.AddItem "e"
End With
End Sub

Steve wrote:

I have a userform with listbox set to multi select which gets list from a
worksheet. I want to be able to select a selection from the list and that
selection to go into another worksheet. Please can anyone help with this?


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,814
Default Multi select Listbox

Thanks for your reply. I have copied the code into the userform but now I'm
getting an error message "runtime error 70", "access denied" when I try and
open userform.

"Dave Peterson" wrote:

Option Explicit
Private Sub CommandButton1_Click()
Dim DestCell As Range
Dim iCtr As Long

With Worksheets("sheet1")
Set DestCell = .Range("A1")
End With

With Me.ListBox1
DestCell.Resize(.ListCount, 1).ClearContents

For iCtr = 0 To .ListCount - 1
If .Selected(iCtr) Then
DestCell.Value = .List(iCtr)
Set DestCell = DestCell.Offset(1, 0)
End If
Next iCtr
End With
End Sub
Private Sub UserForm_Initialize()
With Me.ListBox1
.MultiSelect = fmMultiSelectMulti
.AddItem "a"
.AddItem "b"
.AddItem "c"
.AddItem "d"
.AddItem "e"
End With
End Sub

Steve wrote:

I have a userform with listbox set to multi select which gets list from a
worksheet. I want to be able to select a selection from the list and that
selection to go into another worksheet. Please can anyone help with this?


--

Dave Peterson

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Multi select Listbox

Maybe you should share the code that is causing the trouble--and indicate the
offending line.

And share how you're populating the listbox. If you're using code (.additem),
then make sure the .rowsource is not used (me.listbox1.rowsource = "").

Steve wrote:

Thanks for your reply. I have copied the code into the userform but now I'm
getting an error message "runtime error 70", "access denied" when I try and
open userform.

"Dave Peterson" wrote:

Option Explicit
Private Sub CommandButton1_Click()
Dim DestCell As Range
Dim iCtr As Long

With Worksheets("sheet1")
Set DestCell = .Range("A1")
End With

With Me.ListBox1
DestCell.Resize(.ListCount, 1).ClearContents

For iCtr = 0 To .ListCount - 1
If .Selected(iCtr) Then
DestCell.Value = .List(iCtr)
Set DestCell = DestCell.Offset(1, 0)
End If
Next iCtr
End With
End Sub
Private Sub UserForm_Initialize()
With Me.ListBox1
.MultiSelect = fmMultiSelectMulti
.AddItem "a"
.AddItem "b"
.AddItem "c"
.AddItem "d"
.AddItem "e"
End With
End Sub

Steve wrote:

I have a userform with listbox set to multi select which gets list from a
worksheet. I want to be able to select a selection from the list and that
selection to go into another worksheet. Please can anyone help with this?


--

Dave Peterson


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,814
Default Multi select Listbox

In sheet one I have a command button, (CommandButton1), which opens
UserForm1. The code is:

Private Sub CommandButton1_Click()
UserForm1.Show
End Sub

On UserForm1 I have a List Box, (ListBox9), Which in properties is set for
MultiSelect. ControlSource is 'Sheet4'!A1:A15. Sheet4 A1:A15 has a list of
items.

After inserting your code then using contol button to open user form the
piece of code it stops at is the UserForm1.Show.

Thanks once again for your assistance, hope that's enough information.

"Dave Peterson" wrote:

Maybe you should share the code that is causing the trouble--and indicate the
offending line.

And share how you're populating the listbox. If you're using code (.additem),
then make sure the .rowsource is not used (me.listbox1.rowsource = "").

Steve wrote:

Thanks for your reply. I have copied the code into the userform but now I'm
getting an error message "runtime error 70", "access denied" when I try and
open userform.

"Dave Peterson" wrote:

Option Explicit
Private Sub CommandButton1_Click()
Dim DestCell As Range
Dim iCtr As Long

With Worksheets("sheet1")
Set DestCell = .Range("A1")
End With

With Me.ListBox1
DestCell.Resize(.ListCount, 1).ClearContents

For iCtr = 0 To .ListCount - 1
If .Selected(iCtr) Then
DestCell.Value = .List(iCtr)
Set DestCell = DestCell.Offset(1, 0)
End If
Next iCtr
End With
End Sub
Private Sub UserForm_Initialize()
With Me.ListBox1
.MultiSelect = fmMultiSelectMulti
.AddItem "a"
.AddItem "b"
.AddItem "c"
.AddItem "d"
.AddItem "e"
End With
End Sub

Steve wrote:

I have a userform with listbox set to multi select which gets list from a
worksheet. I want to be able to select a selection from the list and that
selection to go into another worksheet. Please can anyone help with this?

--

Dave Peterson


--

Dave Peterson



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Multi select Listbox

You didn't share the code and you didn't indicate the line that caused the
problem.

I'm guessing that the problem is in the userform_Initialize procedure.

Steve wrote:

In sheet one I have a command button, (CommandButton1), which opens
UserForm1. The code is:

Private Sub CommandButton1_Click()
UserForm1.Show
End Sub

On UserForm1 I have a List Box, (ListBox9), Which in properties is set for
MultiSelect. ControlSource is 'Sheet4'!A1:A15. Sheet4 A1:A15 has a list of
items.

After inserting your code then using contol button to open user form the
piece of code it stops at is the UserForm1.Show.

Thanks once again for your assistance, hope that's enough information.

"Dave Peterson" wrote:

Maybe you should share the code that is causing the trouble--and indicate the
offending line.

And share how you're populating the listbox. If you're using code (.additem),
then make sure the .rowsource is not used (me.listbox1.rowsource = "").

Steve wrote:

Thanks for your reply. I have copied the code into the userform but now I'm
getting an error message "runtime error 70", "access denied" when I try and
open userform.

"Dave Peterson" wrote:

Option Explicit
Private Sub CommandButton1_Click()
Dim DestCell As Range
Dim iCtr As Long

With Worksheets("sheet1")
Set DestCell = .Range("A1")
End With

With Me.ListBox1
DestCell.Resize(.ListCount, 1).ClearContents

For iCtr = 0 To .ListCount - 1
If .Selected(iCtr) Then
DestCell.Value = .List(iCtr)
Set DestCell = DestCell.Offset(1, 0)
End If
Next iCtr
End With
End Sub
Private Sub UserForm_Initialize()
With Me.ListBox1
.MultiSelect = fmMultiSelectMulti
.AddItem "a"
.AddItem "b"
.AddItem "c"
.AddItem "d"
.AddItem "e"
End With
End Sub

Steve wrote:

I have a userform with listbox set to multi select which gets list from a
worksheet. I want to be able to select a selection from the list and that
selection to go into another worksheet. Please can anyone help with this?

--

Dave Peterson


--

Dave Peterson


--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
code to parse a multi-colum multi-select listbox Jade Excel Programming 1 September 16th 08 03:47 PM
identifying multi-select items in a listbox JT Excel Programming 1 January 7th 08 09:14 PM
Listbox Multi Select MikeT Excel Programming 2 July 27th 06 08:25 PM
Multi-select listbox help! John[_60_] Excel Programming 3 October 9th 04 01:57 AM
multi select listbox Paul Mueller Excel Programming 2 June 10th 04 09:08 PM


All times are GMT +1. The time now is 09:47 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"