PC Review


Reply
Thread Tools Rate Thread

2 Column ListBox, Selection data

 
 
ironhydroxide
Guest
Posts: n/a
 
      3rd Aug 2009
I have a 2Column Listbox. I do not know how to get both columns to
variables, i have tried multiple ways and can seem to only get the first
column (which the User has Highlighted) into a variable. How do i get both
values (either in Lines down, or in a string format) into either two
variables or an array. Thanks

Ironhydroxide
 
Reply With Quote
 
 
 
 
ryguy7272
Guest
Posts: n/a
 
      3rd Aug 2009
Maybe this:
http://www.contextures.com/xldataval02.html
http://www.contextures.com/xlDataVal13.html

HTH,
Ryan---

--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.


"ironhydroxide" wrote:

> I have a 2Column Listbox. I do not know how to get both columns to
> variables, i have tried multiple ways and can seem to only get the first
> column (which the User has Highlighted) into a variable. How do i get both
> values (either in Lines down, or in a string format) into either two
> variables or an array. Thanks
>
> Ironhydroxide

 
Reply With Quote
 
ironhydroxide
Guest
Posts: n/a
 
      3rd Aug 2009
Apparently I was not clear in my orignal Post. I have a 2Column ListBox in
my Userform. and so the links dont help me at all. but thanks anyway.


"ryguy7272" wrote:

> Maybe this:
> http://www.contextures.com/xldataval02.html
> http://www.contextures.com/xlDataVal13.html
>
> HTH,
> Ryan---
>
> --
> Ryan---
> If this information was helpful, please indicate this by clicking ''Yes''.
>
>
> "ironhydroxide" wrote:
>
> > I have a 2Column Listbox. I do not know how to get both columns to
> > variables, i have tried multiple ways and can seem to only get the first
> > column (which the User has Highlighted) into a variable. How do i get both
> > values (either in Lines down, or in a string format) into either two
> > variables or an array. Thanks
> >
> > Ironhydroxide

 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      3rd Aug 2009
This worked ok for me:

Option Explicit
Private Sub CommandButton1_Click()
With Me.ListBox1
If .ListIndex < 0 Then
Exit Sub 'nothing selected
End If

MsgBox .List(.ListIndex, 0) & vbLf & .List(.ListIndex, 1)
End With
End Sub
Private Sub UserForm_Initialize()
With Me.ListBox1
.ColumnCount = 2
.ColumnWidths = "33;33"
.List = Worksheets("sheet1").Range("A1:B5").Value
End With
End Sub



ironhydroxide wrote:
>
> I have a 2Column Listbox. I do not know how to get both columns to
> variables, i have tried multiple ways and can seem to only get the first
> column (which the User has Highlighted) into a variable. How do i get both
> values (either in Lines down, or in a string format) into either two
> variables or an array. Thanks
>
> Ironhydroxide


--

Dave Peterson
 
Reply With Quote
 
ironhydroxide
Guest
Posts: n/a
 
      3rd Aug 2009

..ListIndex That is what i needed. Thanks a ton

ironhydroxide

"Dave Peterson" wrote:

> This worked ok for me:
>
> Option Explicit
> Private Sub CommandButton1_Click()
> With Me.ListBox1
> If .ListIndex < 0 Then
> Exit Sub 'nothing selected
> End If
>
> MsgBox .List(.ListIndex, 0) & vbLf & .List(.ListIndex, 1)
> End With
> End Sub
> Private Sub UserForm_Initialize()
> With Me.ListBox1
> .ColumnCount = 2
> .ColumnWidths = "33;33"
> .List = Worksheets("sheet1").Range("A1:B5").Value
> End With
> End Sub
>
>
>
> ironhydroxide wrote:
> >
> > I have a 2Column Listbox. I do not know how to get both columns to
> > variables, i have tried multiple ways and can seem to only get the first
> > column (which the User has Highlighted) into a variable. How do i get both
> > values (either in Lines down, or in a string format) into either two
> > variables or an array. Thanks
> >
> > Ironhydroxide

>
> --
>
> Dave Peterson
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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 Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Listbox column selection John Microsoft Access 3 12th May 2008 04:43 AM
Listbox Selection Displays the Column. Scott Halper Microsoft Excel Worksheet Functions 3 3rd Feb 2007 10:36 AM
Listbox Selection Displays the Column. Scott Halper Microsoft Excel Worksheet Functions 0 1st Feb 2007 08:50 PM
Listbox Selection Displays the Column. Scott Halper Microsoft Excel Worksheet Functions 0 1st Feb 2007 08:50 PM
Listbox Selection Displays the Column. Scott Halper Microsoft Excel Worksheet Functions 0 1st Feb 2007 08:50 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:58 PM.