Forum Discussion

osmanmkc's avatar
osmanmkc
Copper Contributor
Sep 12, 2021

Delete multiple lines

Hi there! 

I use excel for the auctions I organize on the internet. Each line contains the features of a product. When an auction ends, I manually delete the sold products one by one and repost the unsold products. This process takes some time as approximately 3000 items and 400-500 items are sold at each auction. I have a list of the line numbers of the products sold and can I delete the products in one go this way? For example, if the 2nd, 3rd, 7th and 15th products are sold out of the first 20 products, how can I delete these lines at once?


Thanks in advance.

 

6 Replies

  • NikolinoDE's avatar
    NikolinoDE
    Platinum Contributor

    osmanmkc 

    Here is a small example with VBA.

    Assume that when column "E" is on zero it deletes the respective row.

    You can determine the column and value (number and / or text) yourself.

    Sample file included :))

     

    Sub Delrows()
       Dim i As Long
       Application.ScreenUpdating = False
       For i = Cells(Rows.Count, 1).End(xlUp).Row To 1 Step -1
          If Cells(i, 5) = "0" Then Rows(i).Delete
       Next i
       Application.ScreenUpdating = True
    End Sub

     

     

    I would be happy to know if I could help.

     

    Nikolino

    I know I don't know anything (Socrates)

     

    Was the answer useful? Mark them as helpful!

    This will help all forum participants.

  • osmanmkc 

    With the rows that you want to remove selected, as in your screenshot, right-click any of the selected row numbers on the left hand side, then select Delete from the context menu.

    • osmanmkc's avatar
      osmanmkc
      Copper Contributor
      No, that's not what I was asking. This is my job. What I'm asking is how can I speed up the selection process. I have an excel file with 3000 lines and I want to delete 500 lines with specific line numbers from it, how can I speed up this process instead of selecting them one by one?
      • osmanmkc 

        If you use an empty column in which you enter something, for example an "x" if the row is to be deleted, you can filter the data to display only the rows with an "x", delete the filtered rows in one go, then remove the filter.

        Or do you have another way to specify which rows to delete?

Resources