+ Reply to Thread
Results 1 to 6 of 6

Listbox to delete data

  1. #1
    Registered User
    Join Date
    02-07-2012
    Location
    Michigan
    MS-Off Ver
    Excel 2007
    Posts
    8

    Listbox to delete data

    I need some help. I want to create a macro that will pull up a userform list box that will give the user a choice of data to delete. The information is in the excel sheet but as there is hidden data that needs to be deleted and I do not want them to delete the entire row as the will affect other data. I was hoping to do this through a userform as they can just select the the specific data to be deleted and then I can have the macro remove the hidden data.

    I know how to create the userform and select the correct data. What I am not sure is how to take the input selections from the user and convert that into cell locations to determine what data needs to be deleted. Once I have that then I can determine what cells and offsets need to cleared and then sort the list to get the updated list of data.

    Thanks!

  2. #2
    Valued Forum Contributor MaczaQ's Avatar
    Join Date
    06-03-2011
    Location
    Poland
    MS-Off Ver
    Excel 2003 / XP
    Posts
    510

    Re: Listbox to delete data

    post your workbook with dummy data and presented what have to be delete - then I will assist You to code necessary solution
    Best Regards
    MaczaQ
    ---------------------------------------------------------------------------------------------------------------------------
    If you are satisfied with the solution(s) provided, please mark your thread as Solved
    If you are pleased with my answer consider to rate it. To thank someone who has helped you, click on the star icon below their name.
    - This way you will add him some reputation points ... thanks in advance.

  3. #3
    Registered User
    Join Date
    02-07-2012
    Location
    Michigan
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: Listbox to delete data

    Here is a simplified file, though my data is not showing right in the listbox, but you can see what I am trying to do. The problem is once the data is selected I do not know how to use it to determine what data has been selected so that I can use the macro to clear the required cells.
    Attached Files Attached Files

  4. #4
    Valued Forum Contributor MaczaQ's Avatar
    Join Date
    06-03-2011
    Location
    Poland
    MS-Off Ver
    Excel 2003 / XP
    Posts
    510

    Re: Listbox to delete data

    Hi tiggerzen,

    I've wrote below modification for You - I hope I understood your need correctly - copy all below code into your Userform (append old code)

    I had following ideas:
    1. change DRecord_Initialize() into Userform_Initialize for handle initialize event
    2. move part of code for list initalization into outside procedure LoadListItems
    3. change listbox1 properties (MultiSelect) from 0 to 1 value (allow to multiselection)
    4. First item on list have always zero index and you know .ListCount value, so you can use it to determine what you have to delete (.selected() on list[listindex] + start row index) - see procedure DeleteSelectedItems, or just move through all items on list and delete them DeleteSelectedItems "all"

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    02-07-2012
    Location
    Michigan
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: Listbox to delete data

    I updated the code as you indicated but it is not listing the data. The listbox is coming up blank for data (which is causing other problems).

    I can't figure out why it is not displaying the data correctly. Do you see anything wrong?

    Thanks for the help.
    Attached Files Attached Files

  6. #6
    Valued Forum Contributor MaczaQ's Avatar
    Join Date
    06-03-2011
    Location
    Poland
    MS-Off Ver
    Excel 2003 / XP
    Posts
    510

    Re: Listbox to delete data

    Try to work with provided example
    Attached Files Attached Files

+ 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