#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default listbox

I already posted this question in Excel, bur I think this is a better place:

I want to make a selection (entire row) from a worksheet en place this row(s)
in a listbox.
So far I'm able to place the cells from the selected row vertically in the
listbox, but I want the row horizontaly (in columns) placed in the listbox.
When I use the next formula, I get all the rows horizontally

With ListBox1
.ColumnCount = Range("rFactTot").Columns.Count
.RowSource = "rFactTot"
.ListIndex = 0
.MultiSelect = fmMultiSelectMulti
.ListStyle = fmListStyleOption
End With

But I want to add an if--then statement that only places the complete rows
which meet the criteria from "rFactTot" I want.

Anybody knows the solution??


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,163
Default listbox

To populate the listbox use the .List property of the listbox which lets you
specify individual items (row, column) using indexes:
Dim i as Integer, j as Integer, ThisRow as Range
i = 0
For Each ThisRow in Range("rFactTot").Rows
' Use your If statement to specify the criteria from the row:
If ThisRow.Cells(?,?)=? Then
i = i + 1
For j = 1 to Range("rFactTot").Columns.Count
ListBox1.List(i-1,j-1)
Next j
End If
Next ThisRow

--
- K Dales


"luthor" wrote:

I already posted this question in Excel, bur I think this is a better place:

I want to make a selection (entire row) from a worksheet en place this row(s)
in a listbox.
So far I'm able to place the cells from the selected row vertically in the
listbox, but I want the row horizontaly (in columns) placed in the listbox.
When I use the next formula, I get all the rows horizontally

With ListBox1
.ColumnCount = Range("rFactTot").Columns.Count
.RowSource = "rFactTot"
.ListIndex = 0
.MultiSelect = fmMultiSelectMulti
.ListStyle = fmListStyleOption
End With

But I want to add an if--then statement that only places the complete rows
which meet the criteria from "rFactTot" I want.

Anybody knows the solution??


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 B conditional of input in Listbox A Kim K Excel Discussion (Misc queries) 1 October 31st 06 08:27 PM
avoiding duplicates in listbox (added from another listbox) KR Excel Programming 4 March 14th 06 08:17 PM
VBA: Creating listbox similar to the one in Pivot table (Listbox+Checkbox) modjoe23 Excel Programming 3 August 18th 05 02:35 PM
listbox.value not equal to listbox.list(listbox.listindex,0) ARB Excel Programming 0 October 22nd 03 12:46 AM
Is refreshing listbox rowsource in listbox click event possible? Jeremy Gollehon[_2_] Excel Programming 4 September 25th 03 06:45 PM


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

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"