Thread: listbox
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
K Dales[_2_] K Dales[_2_] is offline
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??