+ Reply to Thread
Results 1 to 15 of 15

Delete item from listbox and row source/named range

  1. #1
    Registered User
    Join Date
    11-19-2014
    Location
    England
    MS-Off Ver
    2010
    Posts
    43

    Delete item from listbox and row source/named range

    Hi all,

    I've been searching for a bit of code which simply allows a user to select an item from my listbox on a userform and click a delete button which removes the item from the listbox and the named range on Sheet1.

    The listbox is a multicolumn listbox which has 9 columns. It is linked to a named range on sheet1 called "ServiceList". The range is from A3:I300 (spanning across 9 columns: A to I).

    Any help much appreciated.

    Thanks

  2. #2
    Forum Expert skywriter's Avatar
    Join Date
    06-09-2014
    Location
    USA
    MS-Off Ver
    2016
    Posts
    2,760

    Re: Delete item from listbox and row source/named range

    You should attach the actual workbook.

    View Pic
    Click the * Add Reputation button in the lower left hand corner of this post to say thanks.

    Don't forget to mark this thread SOLVED by going to the "Thread Tools" drop down list above your first post and choosing solved.

  3. #3
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Delete item from listbox and row source/named range

    Remove the selected row from the named range and then update the RowSource property of the listbox.
    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

  4. #4
    Registered User
    Join Date
    11-19-2014
    Location
    England
    MS-Off Ver
    2010
    Posts
    43

    Re: Delete item from listbox and row source/named range

    Thanks Norie, this works brilliantly.

    Thanks

  5. #5
    Registered User
    Join Date
    05-19-2017
    Location
    Karachi
    MS-Off Ver
    2016
    Posts
    4

    Re: Delete item from listbox and row source/named range

    it is deleting only the last selected row, what if I have multiple selection in my Listbox?

  6. #6
    Registered User
    Join Date
    05-19-2017
    Location
    Karachi
    MS-Off Ver
    2016
    Posts
    4

    Re: Delete item from listbox and row source/named range

    Quote Originally Posted by Norie View Post
    Remove the selected row from the named range and then update the RowSource property of the listbox.
    Please Login or Register  to view this content.
    it is deleting only the last selected row, what if I have multiple selection in my Listbox?

  7. #7
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Delete item from listbox and row source/named range

    That wasn't mentioned in the original post, or subsequent posts.

    Might be an idea to start your own, new thread for that.

  8. #8
    Registered User
    Join Date
    09-15-2016
    Location
    VENEZUELA
    MS-Off Ver
    2016
    Posts
    2

    Re: Delete item from listbox and row source/named range

    hi i have been trying to delete from the listbox and from the rowsource, the problem is that my rowsource is a dynamic range and every time i delete the last item there rowsource goes bad or looses its configuration =DESREF(GIRO!#¡REF!;;;CONTARA(GIRO!$A$2:$A$1598);27) or if i use a fixed range as giroA2:G100 every time i delete a row the range gets smaller eventually will get to 0. Can some one help

  9. #9
    Registered User
    Join Date
    09-15-2016
    Location
    VENEZUELA
    MS-Off Ver
    2016
    Posts
    2

    Re: Delete item from listbox and row source/named range

    i using similar code as these one

    Dim idx As Long

    With ListBox1
    idx = .ListIndex
    If idx>-1 Then
    Range("ServiceList").Rows(idx+1).Delete xlShiftUp
    .RowSource = "ServiceList
    End If
    End With

  10. #10
    Registered User
    Join Date
    11-12-2019
    Location
    Mexico
    MS-Off Ver
    Microsoft Office 2019
    Posts
    20

    Re: Delete item from listbox and row source/named range

    Your code worked perfectly for me.

    I have, nevertheless, other issue. I have 2 Userforms, which have listboxes (with multiple columns).

    On the first one, the entries of my listbox are added via a command button which gathers information from other text boxes and combo boxes in the userform. At the same time, there is a text box which adds the numerical values from a column (expenses column) on my listbox . Naturally, when I use your code to delete a row from the column, the value in my total amount text box remains unchanged.

    I have tried several ways to make such substraction, without any success.
    Any suggestions?

    Thanks in advance.

  11. #11
    Registered User
    Join Date
    11-12-2019
    Location
    Mexico
    MS-Off Ver
    Microsoft Office 2019
    Posts
    20

    Re: Delete item from listbox and row source/named range

    Quote Originally Posted by Norie View Post
    Remove the selected row from the named range and then update the RowSource property of the listbox.
    Please Login or Register  to view this content.

    Your code worked perfectly for me.

    I have, nevertheless, other issue. I have 2 Userforms, which have listboxes (with multiple columns).

    On the first one, the entries of my listbox are added via a command button which gathers information from other text boxes and combo boxes in the userform. At the same time, there is a text box which adds the numerical values from a column (expenses column) on my listbox . Naturally, when I use your code to delete a row from the column, the value in my total amount text box remains unchanged.

    I have tried several ways to make such substraction, without any success.
    Any suggestions?

  12. #12
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Delete item from listbox and row source/named range

    Can you start a new thread for your question?

  13. #13
    Registered User
    Join Date
    11-12-2019
    Location
    Mexico
    MS-Off Ver
    Microsoft Office 2019
    Posts
    20

    Re: Delete item from listbox and row source/named range

    Sure,

    I'm new to the forum so I'm unable to post the link to my new thread.
    Is there any way I can send you the link?

    Many thanks.

  14. #14
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Delete item from listbox and row source/named range


  15. #15
    Registered User
    Join Date
    11-12-2019
    Location
    Mexico
    MS-Off Ver
    Microsoft Office 2019
    Posts
    20

    Re: Delete item from listbox and row source/named range

    Yes it is

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] delete listbox item and off sheet
    By cfinch100 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-11-2014, 05:53 AM
  2. [SOLVED] VBA delete an item from source of combo box
    By shayej in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 06-06-2014, 11:24 AM
  3. Delete an item from listbox
    By questionguy in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-19-2013, 12:27 PM
  4. Delete row source from selected line in ListBox
    By PinkMafia14 in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 02-12-2013, 03:15 PM
  5. [SOLVED] Delete a Item from a Listbox.
    By abhay_547 in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 10-20-2010, 11:56 AM

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