Consulting

Results 1 to 3 of 3

Thread: Quickly delete rows with value > 80%

  1. #1
    VBAX Regular
    Joined
    May 2007
    Posts
    72
    Location

    Quickly delete rows with value > 80%

    I have a very large range of data, about 20000 rows give or take starting from column b to fw. I need a macro to quickly delete rows that have a value greather than 80% in column FW. Please help!
    Thanks...
    az

  2. #2
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Probably easiest with a helper column FX in this case; adjust to suit.
    [vba]
    Option Explicit
    Sub DelRows()
    Dim Rw As Long, Find80 As Long
    On Error GoTo Exits
    Application.Calculation = xlCalculationManual
    Rw = Cells(Rows.Count, "FW").End(xlUp).Row
    Range("FX1") = 1
    Range(Cells(1, "FX"), Cells(Rw, "FX")).DataSeries Rowcol:=xlColumns, Step:=1

    Columns("B:FX").Sort Key1:=Range("FW1"), Order1:=xlDescending, Header:=xlNo _
    , OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom

    Find80 = Application.Match(0.8, Columns("FW"), -1)

    Rows(1 & ":" & Find80).Delete

    Columns("B:FX").Sort Key1:=Range("FX1"), Order1:=xlAscending, Header:=xlNo _
    , OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom

    Columns("FX").ClearContents
    Exits:
    Application.Calculation = xlCalculationAutomatic
    End Sub

    [/vba]
    Last edited by mdmackillop; 10-30-2008 at 02:18 PM. Reason: Calculation line position changed
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  3. #3
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Just a thought.
    You may want to turn off automatic calculation to speed things up if you have a lot of formulae in your sheet.
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •