pcarmour
01-13-2014, 01:28 PM
Hi,
I am trying to delete all rows that have a positive values in column "H".
I have tried the following which did work but now crashes excel:
Sub pca()
Dim rng As Range, Cell As Range, del As Range
Dim rngNew As Range
Dim rngDelete As Range
Dim aCell As Range
Dim lastRow As Long
Set rng = Intersect(Range("Free_Money"), ActiveSheet.UsedRange)
For Each Cell In rng
If (Cell.Value) > 0 _
Then
If del Is Nothing Then
Set del = Cell
Else: Set del = Union(del, Cell)
End If
End If
Next Cell
On Error Resume Next
del.EntireRow.Delete
End Sub
Please see attached which has 45,000 rows of data in the original file - reduced for the download, is this size the problem?
Any help as always is really appreciated.
I am working with Windows Home Premium version 6.1.7601 SP 1 Build 7601and Excel version 14.0.6123.5001 (32 bit)
I am trying to delete all rows that have a positive values in column "H".
I have tried the following which did work but now crashes excel:
Sub pca()
Dim rng As Range, Cell As Range, del As Range
Dim rngNew As Range
Dim rngDelete As Range
Dim aCell As Range
Dim lastRow As Long
Set rng = Intersect(Range("Free_Money"), ActiveSheet.UsedRange)
For Each Cell In rng
If (Cell.Value) > 0 _
Then
If del Is Nothing Then
Set del = Cell
Else: Set del = Union(del, Cell)
End If
End If
Next Cell
On Error Resume Next
del.EntireRow.Delete
End Sub
Please see attached which has 45,000 rows of data in the original file - reduced for the download, is this size the problem?
Any help as always is really appreciated.
I am working with Windows Home Premium version 6.1.7601 SP 1 Build 7601and Excel version 14.0.6123.5001 (32 bit)