+ Reply to Thread
Results 1 to 4 of 4

Edit listbox selected items and save to workbook???

Hybrid View

  1. #1
    Registered User
    Join Date
    04-06-2012
    Location
    Portugal
    MS-Off Ver
    Excel 2003
    Posts
    5

    Edit listbox selected items and save to workbook???

    Hi guys i was wondering if it's possible to edit the values of selected items in a listbox and save them to the workbook and update de listbox???

    thank you for your precious help :-)

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,486

    Re: Edit listbox selected items and save to workbook???

    Hello,
    You have not mentioned what type of listbox this is, I will assume it is from the controls tool bar, as the code is compatible with a userform
    You cannot edit the list box items in the list box, you can select the item and send it to a textbox, in the textbox you can edit, then send it back to your source range, then repopulate the list box.
    This is the code you will find in the sheet module.
    Private Sub CommandButton1_Click()
        ListBox1.List = Range("A1:A8").Value
    End Sub
    
    Private Sub CommandButton2_Click()
        Dim OldS As String, Vl As Range, NewS As String, c As Range
        OldS = ListBox1
        NewS = TextBox1
        Set Vl = Range("A1:A8")
        For Each c In Vl.Cells
            If c = OldS Then c = NewS
        Next c
        ListBox1.List = Range("A1:A8").Value
    
    End Sub
    
    Private Sub ListBox1_Click()
        TextBox1 = ListBox1
    End Sub
    Click the Populate Listbox button
    Select an item from listbox to send it to the textbox
    Edit the Textbox item
    Click the button to reset the list box.

    See attached example
    Attached Files Attached Files

  3. #3
    Registered User
    Join Date
    04-06-2012
    Location
    Portugal
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Edit listbox selected items and save to workbook???

    Thank you so much Dave for your help but can i edit the value in a especific column of a listbox? In my attached file i would lite to edit the Quantity column of a selected line with a button calling a msg box to input the new data...

    i´ve translated the userform i want to change to english (RED Userform) the rest of it is in Portuguese...

    Stock form.xls

    I would love any help i can get... Thank You ;-)

  4. #4
    Registered User
    Join Date
    04-06-2012
    Location
    Portugal
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Edit listbox selected items and save to workbook???

    I've tried to change the code to use it with a list box with 6 columns but I don't know how to get it to work :-( any ideas?

+ 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