+ Reply to Thread
Results 1 to 7 of 7

Deleting items from a spreadsheet based off of combo box selection

  1. #1
    Forum Contributor
    Join Date
    05-20-2013
    Location
    Ann Arbor, MI
    MS-Off Ver
    Excel 2010
    Posts
    255

    Deleting items from a spreadsheet based off of combo box selection

    Currently, I have a combo box that is populated from a specific column in a spread sheet. On the userform, there is an Update page where I want the user to be able to choose something already in the combobox, and then press "delete from list." Is there a way for me to this?

    Below is the code i'm currently using, but i'm getting "Run-Time Error '5': Invalid procedure call or argument" (I'm very new to vba)

    Private Sub delLocateBTN_Click()

    With Worksheets("READ ONLY")
    If .Cells("F").Value = DelLocationcb.Value Then
    .Cells("F").Select ' select the row
    Selection.EntireRow.Delete ' now delete the entire row
    ThisWorkbook.Save
    End If
    End With



    End Sub
    Last edited by emilyloz; 05-29-2013 at 09:43 AM.

  2. #2
    Valued Forum Contributor
    Join Date
    11-20-2012
    Location
    Seattle, WA USA
    MS-Off Ver
    Excel 2010
    Posts
    597

    Re: Deleting items from a spreadsheet based off of combo box selection

    you will need a loop to check to see if each of the rows contains the value DelLocationcb.Value, then select the row then delete the row

    something like

    Please Login or Register  to view this content.
    you want to loop backward (ie largest line to smallest) since you will be deleting lines

  3. #3
    Valued Forum Contributor
    Join Date
    11-20-2012
    Location
    Seattle, WA USA
    MS-Off Ver
    Excel 2010
    Posts
    597

    Re: Deleting items from a spreadsheet based off of combo box selection

    you will need a loop to check to see if each of the rows contains the value DelLocationcb.Value, then select the row then delete the row

    something like

    Please Login or Register  to view this content.
    you want to loop backward (ie largest line to smallest) since you will be deleting lines

  4. #4
    Forum Contributor
    Join Date
    05-20-2013
    Location
    Ann Arbor, MI
    MS-Off Ver
    Excel 2010
    Posts
    255

    Re: Deleting items from a spreadsheet based off of combo box selection

    I am using this code, and I'm not getting any errors associated with it, but nothing is happening. The cell is not deleting.

  5. #5
    Forum Contributor
    Join Date
    05-20-2013
    Location
    Ann Arbor, MI
    MS-Off Ver
    Excel 2010
    Posts
    255

    Re: Deleting items from a spreadsheet based off of combo box selection

    Thanks for your help. I decided to use screen updating. It's more practical for my use.

  6. #6
    Valued Forum Contributor
    Join Date
    11-20-2012
    Location
    Seattle, WA USA
    MS-Off Ver
    Excel 2010
    Posts
    597

    Re: Deleting items from a spreadsheet based off of combo box selection

    to ensure you get an answer that fulfills your request in full, post an example workbook that has the same layout as the one that you will be using. there is prob a small change that needs to be made to the code to get it to work. I just gave you an example code that must be modified to actually work

  7. #7
    Forum Contributor
    Join Date
    05-20-2013
    Location
    Ann Arbor, MI
    MS-Off Ver
    Excel 2010
    Posts
    255

    Re: Deleting items from a spreadsheet based off of combo box selection

    Hi Scott,

    Perhaps you could help; based off of the code i'm using to delete items from a combo box, everything works perfect in the VBA window, but when I try to run it from the excel document itself, it's not working. Below is the code:

    Please Login or Register  to view this content.
    I have attached my workbook this time. This code can be found under the userform, 'MelvMaint' at the bottomMillSteel-Reports.xlsm

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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