Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Need help with Listboxes!


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!


--
Angelus
------------------------------------------------------------------------
Angelus's Profile: http://www.excelforum.com/member.php...o&userid=30721
View this thread: http://www.excelforum.com/showthread...hreadid=504144

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Need help with Listboxes!

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.

--
Regards,
Tom Ogilvy



"Angelus" wrote in
message ...

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!


--
Angelus
------------------------------------------------------------------------
Angelus's Profile:

http://www.excelforum.com/member.php...o&userid=30721
View this thread: http://www.excelforum.com/showthread...hreadid=504144



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Need help with Listboxes!


Wow. Thanks a lot!

Tom Ogilvy Wrote:
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.

--
Regards,
Tom Ogilvy



"Angelus" wrote
in
message ...

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!


--
Angelus

------------------------------------------------------------------------
Angelus's Profile:

http://www.excelforum.com/member.php...o&userid=30721
View this thread:

http://www.excelforum.com/showthread...hreadid=504144



--
Angelus
------------------------------------------------------------------------
Angelus's Profile: http://www.excelforum.com/member.php...o&userid=30721
View this thread: http://www.excelforum.com/showthread...hreadid=504144

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Need help with Listboxes!


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.


--
Angelus
------------------------------------------------------------------------
Angelus's Profile: http://www.excelforum.com/member.php...o&userid=30721
View this thread: http://www.excelforum.com/showthread...hreadid=504144

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Need help with Listboxes!


Nevermind, I figured it out.


--
Angelus
------------------------------------------------------------------------
Angelus's Profile: http://www.excelforum.com/member.php...o&userid=30721
View this thread: http://www.excelforum.com/showthread...hreadid=504144

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
listboxes [email protected] Excel Programming 2 March 30th 05 06:41 PM
listboxes [email protected] Excel Programming 3 February 22nd 05 04:01 PM
Listboxes 2 Denise Excel Programming 2 June 8th 04 06:39 PM
listboxes Mandy[_2_] Excel Programming 3 May 7th 04 04:38 PM
Listboxes Lionel Fridjhon Excel Programming 0 April 5th 04 06:28 PM


All times are GMT +1. The time now is 01:16 AM.

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"