Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Autofilter with Sum
Hi all,
I have a macro which delete rows with a sum of zero using autofilter but the marco deletes more than that! I have no idea on the macro now. :( Code: --------------------------------- For h = 1 To arrayH.Count For i = 1 To arrayQ.Count ActiveSheet.Range("A1").AutoFilter Field:=cccCol Criteria1:=arrayQ(i), Operator:=xlAnd ActiveSheet.Range("A1").AutoFilter Field:=acctCol Criteria1:=arrayH(h) With ActiveSheet.AutoFilter.Range On Error Resume Next Set rng = .Offset(1, 0).Resize(.Rows.Count - 1 1).SpecialCells(xlCellTypeVisible) Set rng2 rng.Columns(17).SpecialCells(xlCellTypeVisible) If (Not rng2 = Null) An (Round(Application.WorksheetFunction.Sum(rng2), 0) = 0) Then Debug.Print "Delete " & arrayQ(i) & " " arrayH(h) & " " & _ Application.WorksheetFunction.Sum(rng2) & " " Round(Application.WorksheetFunction.Sum(rng2), 0) rng.EntireRow.Delete End If End With Next i Next h Result: --------------------------------- Delete C111 022701 0 0 Delete C286 022701 -179737.193541667 -179737 Delete C302 022701 0 0 Delete C320 022701 268691 268691 Delete C370 022701 -445900 -445900 Delete C600 022701 119197.992268519 119198 Delete C614 022701 1216707.43701389 1216707 Delete C617 022701 0 0 Delete C939 022701 2.1600499167107E-12 0 Delete CB12 022701 0 0 Delete C505 023101 41669.32 41669 Delete C600 023101 80557.6 80558 Delete CB12 023101 0 0 Delete CH09 023101 0 0 Delete CH40 023101 1200 1200 Delete CM77 023101 11158 1115 -- Message posted from http://www.ExcelForum.com |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Autofilter with Sum
|
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
excel 2007 autofilter change to 2003 autofilter functionality? | Excel Discussion (Misc queries) | |||
2007 excel autofilter back to 2003 autofilter? | Excel Discussion (Misc queries) | |||
2007 excel autofilter change back to 2003 autofilter? | Excel Discussion (Misc queries) | |||
2007 Autofilter worse than 2003 Autofilter | Excel Discussion (Misc queries) | |||
How to Sort within AutoFilter with Protection on (and AutoFilter . | Excel Discussion (Misc queries) |