Results 1 to 3 of 3
  1. #1
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Move value from listbox to sheet (2000 sr 1)

    Why not work?...

    I have a listbox filled with 13 value and i would want to move the value from listbox into sheet started from I1

    Private Sub CommandButton1_Click()
    Dim i As Long
    With Me.ListBox1
    If .ListCount > 0 Then
    For i = 1 To Me.ListBox1.ListCount
    Range("I1").Offset(0, i) = Me.ListBox1.Value
    Next i
    End If
    End With
    End Sub

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Move value from listbox to sheet (2000 sr 1)

    Me.ListBox1.Value is the selected item, not the i-th item.
    The item index of a list box runs from 0 to ListCount -1, not from 1 to ListCount. So use

    For i = 0 To Me.ListBox1.ListCount - 1
    Range("I1").Offset(0, i) = Me.ListBox1.List(i)
    Next i

  3. #3
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Move value from listbox to sheet (2000 sr 1)

    Solved with your help!

Posting Permissions

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