+ Reply to Thread
Results 1 to 2 of 2

listbox

  1. #1
    luthor
    Guest

    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. #2
    K Dales
    Guest

    RE: 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 to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1