Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default code to parse a multi-colum multi-select listbox

Hello Everyone,

I need some help. I need to develop code to parse a multi-column
multi-select listbox and put the values in a worksheet.

This is the code I have but it's only giving me the last item selected
and I need to capture all items selected in the multi-select, multi-
column Listbox.

With Me.ListBox2
For i = 0 To .ListCount - 1
If .Selected(i) Then
UserForm1.Spreadsheet1.Range("a65536").End(xlUp) = sPrompt
& .Column(0, i)
UserForm1.Spreadsheet1.Range("B65536").End(xlUp) = sPrompt
& .Column(1, i)
End If
Next i

Again, any help would be great.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default code to parse a multi-colum multi-select listbox

This worked ok for me:

Option Explicit
Private Sub CommandButton1_Click()
Dim sPrompt As String
Dim iCtr As Long
Dim cCtr As Long
Dim destcell As Range
Dim wks As Worksheet

sPrompt = "a-"
Set wks = Worksheets("sheet2")

With wks
Set destcell = .Cells(.Rows.Count, "A").End(xlUp).Offset(1, 0)
End With

With Me.ListBox2
For iCtr = 0 To .ListCount - 1
If .Selected(iCtr) Then
For cCtr = 0 To .ColumnCount - 1
destcell.Offset(0, cCtr).Value = sPrompt & .List(iCtr, 0)
Next cCtr
Set destcell = destcell.Offset(1, 0)
End If
Next iCtr
End With
End Sub
Private Sub UserForm_Initialize()
Dim myRng As Range

Set myRng = Worksheets("sheet1").Range("a1:b3")
With Me.ListBox2
.ColumnCount = myRng.Columns.Count
.MultiSelect = fmMultiSelectMulti
.List = myRng.Value
End With
End Sub


Jade wrote:

Hello Everyone,

I need some help. I need to develop code to parse a multi-column
multi-select listbox and put the values in a worksheet.

This is the code I have but it's only giving me the last item selected
and I need to capture all items selected in the multi-select, multi-
column Listbox.

With Me.ListBox2
For i = 0 To .ListCount - 1
If .Selected(i) Then
UserForm1.Spreadsheet1.Range("a65536").End(xlUp) = sPrompt
& .Column(0, i)
UserForm1.Spreadsheet1.Range("B65536").End(xlUp) = sPrompt
& .Column(1, i)
End If
Next i

Again, any help would be great.


--

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
Listbox Multi Select MikeT Excel Programming 2 July 27th 06 08:25 PM
Multi Colum Listbox in UserForm Zani Excel Programming 2 January 13th 06 12:05 AM
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
Extract values from a multi-select multi-column list-box Peter[_20_] Excel Programming 5 September 28th 03 04:04 PM


All times are GMT +1. The time now is 11:02 PM.

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

About Us

"It's about Microsoft Excel"