+ Reply to Thread
Results 1 to 5 of 5

populate multicolumn listbox?

  1. #1
    Alen32
    Guest

    populate multicolumn listbox?

    I got thics code here but I can't insert results in listbox.

    With userform1
    if .optionButton1 then
    sOne = "Horse"
    else
    sOne = "Pig"
    end if
    if .optionButton3 then
    sTwo = "Danish"
    else
    sTwo = "Foreign"
    end if
    sThree = .Textbox1.Text
    End With
    With Worksheets(1).Cells
    Set c = .Find(sOne, lookin:=xlValues)
    If Not c Is Nothing Then
    firstAddress = c.Address
    Do
    if application.countif(c.EntireRow,"*" & sTwo & "*") and _
    application.Countif(c.EntireRow,"*" & sThree & "*") then
    ' add row to listbox
    end if
    Set c = .FindNext(c)
    Loop While Not c Is Nothing And c.Address <> firstAddress
    End If
    End With



  2. #2
    Tom Ogilvy
    Guest

    Re: populate multicolumn listbox?

    You just said you wanted to add the row to the listbox. That is
    significantly vague. Obviously you don't want to add 256 cells to the
    listbox. so what do you want to do? What cells in the found code do you
    want to add to the listbox.

    --
    Regards,
    Tom Ogilvy


    "Alen32" <bingo190@yahoo.com> wrote in message
    news:cda18e6265fbe26bdb808797f0a0a58e@localhost.talkaboutsoftware.com...
    > I got thics code here but I can't insert results in listbox.
    >
    > With userform1
    > if .optionButton1 then
    > sOne = "Horse"
    > else
    > sOne = "Pig"
    > end if
    > if .optionButton3 then
    > sTwo = "Danish"
    > else
    > sTwo = "Foreign"
    > end if
    > sThree = .Textbox1.Text
    > End With
    > With Worksheets(1).Cells
    > Set c = .Find(sOne, lookin:=xlValues)
    > If Not c Is Nothing Then
    > firstAddress = c.Address
    > Do
    > if application.countif(c.EntireRow,"*" & sTwo & "*") and _
    > application.Countif(c.EntireRow,"*" & sThree & "*") then
    > ' add row to listbox
    > end if
    > Set c = .FindNext(c)
    > Loop While Not c Is Nothing And c.Address <> firstAddress
    > End If
    > End With
    >
    >




  3. #3
    Alen32
    Guest

    Re: populate multicolumn listbox?

    like her:
    .ListBox1.AddItem cell.Value
    .ListBox1.List(.ListBox1.ListCount - 1, 1) _
    = cell.Offset(0, 2).Value
    .ListBox1.List(.ListBox1.ListCount - 1, 2) _
    = cell.Offset(0, 5).Value



  4. #4
    Tom Ogilvy
    Guest

    Re: populate multicolumn listbox?

    With userform1
    if .optionButton1 then
    sOne = "Horse"
    else
    sOne = "Pig"
    end if
    if .optionButton3 then
    sTwo = "Danish"
    else
    sTwo = "Foreign"
    end if
    sThree = .Textbox1.Text
    End With
    With Worksheets(1).Cells
    Set c = .Find(sOne, lookin:=xlValues)
    If Not c Is Nothing Then
    firstAddress = c.Address
    Do
    if application.countif(c.EntireRow,"*" & sTwo & "*") and _
    application.Countif(c.EntireRow,"*" & sThree & "*") then
    Userform1.ListBox1.AddItem c.Value
    Userform1.ListBox1.List( _
    Userform1.ListBox1.ListCount - 1, 1) _
    = c.Offset(0, 2).Value
    Userform1.ListBox1.List( _
    Userform1.ListBox1.ListCount - 1, 2) _
    = c.Offset(0, 5).Value
    end if
    Set c = .FindNext(c)
    Loop While Not c Is Nothing And c.Address <> firstAddress
    End If
    End With

    Assuming the cell you want to base your offset on is the the one containing
    pig or horse

    --
    Regards,
    Tom Ogilvy


    "Tom Ogilvy" <twogilvy@msn.com> wrote in message
    news:%23CwdInxLFHA.2796@tk2msftngp13.phx.gbl...
    > You just said you wanted to add the row to the listbox. That is
    > significantly vague. Obviously you don't want to add 256 cells to the
    > listbox. so what do you want to do? What cells in the found code do you
    > want to add to the listbox.
    >
    > --
    > Regards,
    > Tom Ogilvy
    >
    >
    > "Alen32" <bingo190@yahoo.com> wrote in message
    > news:cda18e6265fbe26bdb808797f0a0a58e@localhost.talkaboutsoftware.com...
    > > I got thics code here but I can't insert results in listbox.
    > >
    > > With userform1
    > > if .optionButton1 then
    > > sOne = "Horse"
    > > else
    > > sOne = "Pig"
    > > end if
    > > if .optionButton3 then
    > > sTwo = "Danish"
    > > else
    > > sTwo = "Foreign"
    > > end if
    > > sThree = .Textbox1.Text
    > > End With
    > > With Worksheets(1).Cells
    > > Set c = .Find(sOne, lookin:=xlValues)
    > > If Not c Is Nothing Then
    > > firstAddress = c.Address
    > > Do
    > > if application.countif(c.EntireRow,"*" & sTwo & "*") and _
    > > application.Countif(c.EntireRow,"*" & sThree & "*") then
    > > ' add row to listbox
    > > end if
    > > Set c = .FindNext(c)
    > > Loop While Not c Is Nothing And c.Address <> firstAddress
    > > End If
    > > End With
    > >
    > >

    >
    >




  5. #5
    Alen32
    Guest

    Re: populate multicolumn listbox?

    fantastic its working!!!!
    Thanks Tom!!


+ 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