Results 1 to 3 of 3
  1. #1
    Silver Lounger
    Join Date
    Jan 2001
    Location
    Northern, California, USA
    Posts
    1,886
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Listbox Rowsource (97 SR2)

    I have a listbox on a userform. I know that I can specify a range for it's row source: Main!A2:Z500 My question is, what is the syntax for selecting specific rows? I want to have my list box populate with only certian columns: A, E, F, K, L, U.

    Thanks!
    <IMG SRC=http://www.wopr.com/w3tuserpics/Kel_sig.gif>
    Moderator:<font color=448800> Pix Place, Internet Explorer</font color=448800>
    <small>www.kvisions.com

  2. #2
    Bronze Lounger
    Join Date
    Jun 2001
    Location
    New York, New York, Lebanon
    Posts
    1,449
    Thanks
    1
    Thanked 1 Time in 1 Post

    Re: Listbox Rowsource (97 SR2)

    DrkRealm

    There are several ways to do so, but I suggest if the data is not too huge, use a Loop structure.

    Name the columns A,E,F,K,L,U some name, and then use for-each cell looping. Here is an example:

    With .ListBoxToPopulate
    For Each vCellToInclude In DataRange.Cells
    .AddItem vCellToInclude.Value
    Next vCellToInclude
    End With

    where DataRange is the name of the columns you want, or the range of data you want, and vCellToInclude is a variant to help with the For-each loop.

    HTH

    Wassim
    <img src=/S/compute.gif border=0 alt=compute width=40 height=20> in the <img src=/S/bagged.gif border=0 alt=bagged width=22 height=22>

  3. #3
    Silver Lounger
    Join Date
    Jan 2001
    Location
    Northern, California, USA
    Posts
    1,886
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Listbox Rowsource (97 SR2)

    Thanks Wassim!

    I found the simplest method was to set the range to A2:K(Last Row Number)

    Then I modified the column widths to properly display my data, using zeros for the data I didn't want to display.

    I will use a bit of code to determine the last row which contains data, and use that to specify the rowsource for the list box.

    Thanks Millions!
    <IMG SRC=http://www.wopr.com/w3tuserpics/Kel_sig.gif>
    Moderator:<font color=448800> Pix Place, Internet Explorer</font color=448800>
    <small>www.kvisions.com

Posting Permissions

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