If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Microsoft Excel > Place Data from MultiSelect Listbox

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-31-06, 13:14
kwengerd kwengerd is offline
Registered User
 
Join Date: Mar 2005
Posts: 11
Place Data from MultiSelect Listbox

I am having a brain lapse, apparently... I want to simply place a list of data selected from a multi select listbox, that is run in a VBA form, in a spreadsheet. I will then do a lookup to pull additional data from that list. HELP!

THANK YOU!

Keith
Reply With Quote
  #2 (permalink)  
Old 05-31-06, 13:35
norie norie is offline
Registered User
 
Join Date: Mar 2006
Posts: 163
Keith

Is it on a userform?

Where do you want to put the data?
Code:
Private Sub CommandButton1_Click()
Dim I As Long
Dim X As Long
    For I = 0 To ListBox1.ListCount - 1
        If ListBox1.Selected(I) Then
            X = X + 1
            Range("B" & X) = ListBox1.List(I)
        End If
    Next I
End Sub
Reply With Quote
  #3 (permalink)  
Old 05-31-06, 14:37
kwengerd kwengerd is offline
Registered User
 
Join Date: Mar 2005
Posts: 11
I just want to put it in sheet1, column A, Row 1 then 2, etc.
Reply With Quote
  #4 (permalink)  
Old 05-31-06, 14:41
norie norie is offline
Registered User
 
Join Date: Mar 2006
Posts: 163
Well just chnage B to A in the code I posted.
Reply With Quote
  #5 (permalink)  
Old 05-31-06, 14:57
kwengerd kwengerd is offline
Registered User
 
Join Date: Mar 2005
Posts: 11
Actually, I really want it to go start in row 14... which variable do I change for that? Thanks so much for your help already!
Reply With Quote
  #6 (permalink)  
Old 05-31-06, 15:07
norie norie is offline
Registered User
 
Join Date: Mar 2006
Posts: 163
Just put X = 13 before the loop.
Reply With Quote
  #7 (permalink)  
Old 05-31-06, 16:05
kwengerd kwengerd is offline
Registered User
 
Join Date: Mar 2005
Posts: 11
That works great so far, or so I thought. I just realized that if I select one item or a list of items, the first one is not listed. What am I missing? Here's my code:

Dim I As Long
Dim X As Long
X = 13
For I = 10 To ListBox10.ListCount - 1
If ListBox10.Selected(I) Then

X = X + 1
Range("M" & X) = ListBox10.List(I)
End If
Next I
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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