+ Reply to Thread
Results 1 to 3 of 3

Using a listbox to go to specified column

Hybrid View

pprseller Using a listbox to go to... 06-09-2007, 03:28 PM
rylo Hi See if this helps. The... 06-09-2007, 08:01 PM
pprseller Listbox columns 06-15-2007, 03:58 PM
  1. #1
    Registered User
    Join Date
    06-05-2007
    Posts
    81

    Using a listbox to go to specified column

    I am using a listbox that contains 3 columns. I have managed to get the transfer of data to the sheet successfully but I need an empty column in the new worksheet. Is there code that will direct each column to where I want it? Example: List box looks like this:
    Code Size Color
    45 11 Yellow
    46 11 Blue
    The worksheet that this is transferring to needs to look like this:
    Code Qty Size Color
    45 11 Yellow
    46 11 Blue
    (With qty being a number that can be entered after all of the selections are done.)
    I appreciate any help that can be given. Thanks!

  2. #2
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591
    Hi

    See if this helps. The listbox is called listbox1, it is multiselect and the code is from a commandbutton.

    The output is put onto the current sheet and will start in A2 with the output going into columns A, C and D with B left blank.

    Private Sub CommandButton1_Click()
      If ListBox1.ListIndex <> -1 Then
        For i = 0 To ListBox1.ListCount - 1
          If ListBox1.Selected(i) = True Then
            nextrow = Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
            Cells(nextrow, 1).Value = ListBox1.List(i, 0)
            Cells(nextrow, 3).Value = ListBox1.List(i, 1)
            Cells(nextrow, 4).Value = ListBox1.List(i, 2)
          End If
        Next i
      End If
    End Sub

    HTH

    rylo

  3. #3
    Registered User
    Join Date
    06-05-2007
    Posts
    81

    Listbox columns

    Thank you!

+ 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