+ Reply to Thread
Results 1 to 13 of 13

VBA delete entire row from rowsource with listbox

  1. #1
    Forum Contributor
    Join Date
    02-22-2011
    Location
    South Africa
    MS-Off Ver
    Excel 2010
    Posts
    108

    VBA delete entire row from rowsource with listbox

    Hi

    I have a listbox that add items from a rowsource, i want to add a delete command button to the form so that i can delete an item from the listbox and that should also delete the entire row from the rowsource.

    I have a code but it's only removing the item from the list box and not from the rowsource?

    Can someone advise me where the problem might be?

    Please Login or Register  to view this content.

  2. #2
    Forum Contributor
    Join Date
    02-22-2011
    Location
    South Africa
    MS-Off Ver
    Excel 2010
    Posts
    108

    Re: VBA delete entire row from rowsource with listbox

    Any help please??

  3. #3
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643
    Have you stepped through the code to see what's happening?

    Perhaps there's another method to find the row to delete.

    For example if the listbox is populated from a contiguous range you could use it's ListIndex property.
    If posting code please use code tags, see here.

  4. #4
    Forum Contributor
    Join Date
    02-22-2011
    Location
    South Africa
    MS-Off Ver
    Excel 2010
    Posts
    108

    Re: VBA delete entire row from rowsource with listbox

    Norie,

    I found the code on the internet so i'm not sure where and what the problem is.

    As for your answer yes i using a range to populate my listbox...

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

    Re: VBA delete entire row from rowsource with listbox

    I can't see where your code deletes a value from the listbox.

    It does have code to delete from a range though.

    Also, how exactly have you populated the listbox and what's the name of the range?

    Can you post a sample workbook? That might help.

  6. #6
    Forum Contributor
    Join Date
    02-22-2011
    Location
    South Africa
    MS-Off Ver
    Excel 2010
    Posts
    108

    Re: VBA delete entire row from rowsource with listbox

    Norie

    I found that it does actually delete a row but it is the first row of the listbox...


    Why will that happen?

  7. #7
    Forum Contributor
    Join Date
    02-22-2011
    Location
    South Africa
    MS-Off Ver
    Excel 2010
    Posts
    108

    Re: VBA delete entire row from rowsource with listbox

    Please any assistance?

  8. #8
    Forum Contributor
    Join Date
    02-22-2011
    Location
    South Africa
    MS-Off Ver
    Excel 2010
    Posts
    108

    Re: VBA delete entire row from rowsource with listbox

    Attached is the file i'm working on can some please try and assist me to add a delete function to the listbox that will delete the item from the list box and from the rowsource...

    Master Downtime Report V5.1.5.xlsm

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

    Re: VBA delete entire row from rowsource with listbox

    Which userform/listbox should we be looking at?

    I can't find a sub called Delete_item_Click anywhere.

  10. #10
    Forum Contributor
    Join Date
    02-22-2011
    Location
    South Africa
    MS-Off Ver
    Excel 2010
    Posts
    108

    Re: VBA delete entire row from rowsource with listbox

    Norie,

    It is on the DataFilter userform...

    There is no Delete button yet as i had to remove because the users were using it and it deleted the wrong data...

  11. #11
    Forum Contributor
    Join Date
    02-22-2011
    Location
    South Africa
    MS-Off Ver
    Excel 2010
    Posts
    108

    Re: VBA delete entire row from rowsource with listbox

    Norie,

    It is on the DataFilter userform...

    There is no Delete button yet as i had to remove because the users were using it and it deleted the wrong data...

  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: VBA delete entire row from rowsource with listbox

    I've found the form and listbox.

    When do you want to delete?

    Also, I can't access any of the hidden worksheets because the workbook/worksheets are protected.

  13. #13
    Forum Contributor
    Join Date
    02-22-2011
    Location
    South Africa
    MS-Off Ver
    Excel 2010
    Posts
    108

    Re: VBA delete entire row from rowsource with listbox

    Norie,

    I want a user to select one of the rows in the listbox for example a duplicate entry ect and then he should be able to delete the record with a delete button.

    With regards to the protection passwords are "Admin"

    Hope you can help me??

+ 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