Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / January 2006

Tip: Looking for answers? Try searching our database.

Need help with Listboxes!

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Angelus - 23 Jan 2006 19:11 GMT
Alright, so here is my situation. I've tried to get this to work for a
while now...and just can't seem to figure it out.

Let's say you have columns A, B, C with data in them. Column D is a
boolean value...true/false, 0/1, whatever.

How would I populate a multi-column listbox with the data from A, B,
and C depending on whether D is 0 or 1. So if it's 0, I want that row
in the listbox, but if it's 1, I don't want it in the listbox. Of
course I'd like this to work on all rows in the sheet.

Could someone help me with the code for that?

Thank you very much!

Signature

Angelus

Tom Ogilvy - 23 Jan 2006 19:23 GMT
Private Sub UserForm_Initialize()
Dim rng As Range
ListBox1.ColumnCount = 4
Set rng = Range(Cells(2, 1), Cells(2, 1).End(xlDown))
For Each cell In rng
 If cell.Offset(0, 3) = 0 Then
    ListBox1.AddItem cell.Value
    ListBox1.List(ListBox1.ListCount - 1, 1) = cell.Offset(0, 1).Value
    ListBox1.List(ListBox1.ListCount - 1, 2) = cell.Offset(0, 2).Value
    ListBox1.List(ListBox1.ListCount - 1, 3) = cell.Offset(0, 3).Value
 End If
Next

End Sub

worked for me.

Signature

Regards,
Tom Ogilvy

> Alright, so here is my situation. I've tried to get this to work for a
> while now...and just can't seem to figure it out.
[quoted text clipped - 10 lines]
>
> Thank you very much!
Angelus - 23 Jan 2006 20:03 GMT
Wow. Thanks a lot!

Tom Ogilvy Wrote:
> Private Sub UserForm_Initialize()
> Dim rng As Range
[quoted text clipped - 42 lines]
> > View this thread:
> http://www.excelforum.com/showthread.php?threadid=504144

Signature

Angelus

Angelus - 24 Jan 2006 03:27 GMT
Okay, I need a little more help here.

Once an entry in the listbox is selected and a command button is
pushed, how do I get the value of the second column?

It would be something like:

newVariable = ListBox1.List(X, 1)

What do I put where the X is to specify the entry that has been
selected? Thanks.

Signature

Angelus

Angelus - 24 Jan 2006 04:50 GMT
Nevermind, I figured it out.

Signature

Angelus

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.