Results 1 to 14 of 14

Delete a group of rows with a condition

Threaded View

ducky6 Delete a group of rows with a... 09-29-2010, 11:07 AM
pike Re: Delete a group of rows... 09-30-2010, 04:15 AM
ducky6 Re: Delete a group of rows... 09-30-2010, 08:45 AM
ducky6 Re: Delete a group of rows... 09-30-2010, 09:56 AM
pike Re: Delete a group of rows... 10-02-2010, 04:56 AM
ducky6 Re: Delete a group of rows... 10-03-2010, 07:08 AM
pike Re: Delete a group of rows... 10-03-2010, 07:20 AM
ducky6 Re: Delete a group of rows... 10-04-2010, 03:49 AM
davesexcel Re: Delete a group of rows... 10-04-2010, 06:59 AM
pike Re: Delete a group of rows... 10-04-2010, 07:18 AM
ducky6 Re: Delete a group of rows... 10-04-2010, 08:46 AM
davesexcel Re: Delete a group of rows... 10-04-2010, 11:03 AM
ducky6 Re: Delete a group of rows... 10-05-2010, 06:06 AM
davesexcel Re: Delete a group of rows... 10-18-2010, 09:31 PM
  1. #1
    Registered User
    Join Date
    08-23-2010
    Location
    Duckland
    MS-Off Ver
    Excel 2007
    Posts
    18

    Delete a group of rows with a condition

    Hi, everybody
    I use this macro to delete rows with a lower amount compared to the one specified by the user:

    Sub DeleteRows()
        Dim ur As Integer
        Dim limit$
        limit = InputBox("Delete rows with amount lower than:", "INSERT THE AMOUNT")
        With Sheets("mySheet")
            ur = .Cells(Rows.Count, 22).End(xlUp).Row
            For n = ur To 2 Step -1
                If .Cells(n, 22).Value < CLng(limit) Then
                    .Cells(n, 22).EntireRow.Delete
            End If
            Next n
        End With
        MsgBox ("Operation completed successfully")
    End Sub
    Now I need something more. Let's assume that those amounts are related to some client: I have to delete ALL the rows related to a client, if none of them reach the amount specified by the user.

    For example:
    Client A - 25
    Client A - 29
    Client A - 35
    Client B - 28
    Client B - 26
    Client B - 29
    If the limit is 30, I must keep all of rows for Client A, and delete all of rows for Client B.

    I hope my explanation was quite clear...
    Any help is welcome,
    thank you in advance!
    Last edited by davesexcel; 10-18-2010 at 09:29 PM.

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