Okay, I tried utilizing this code to look in Column U for anythin
that's not D6 and delete that row. Here's what I got but the debu
keeps pointing to the ActiveSheet.ShowAllData part of the code.
don't understand, what Tom put works perfectly on my previous project.
What am I doing wrong in this code?
Dim rng As Range, rng1 As Range
Range("U1").CurrentRegion.AutoFilter _
Field:=3, Criteria1:="<D6", Operator:=xlAnd
Set rng = Intersect(ActiveSheet.AutoFilter.Range, Columns(3))
Set rng = rng.Offset(1, 0).Resize(rng.Rows.Count - 1, 1)
On Error Resume Next
Set rng1 = rng.SpecialCells(xlVisible)
On Error GoTo 0
If Not rng1 Is Nothing Then
rng1.EntireRow.Delete
End If
ActiveSheet.ShowAllData
Range("U1").CurrentRegion.AutoFilter
Tom Ogilvy Wrote:
Sub DeleteData()
Dim rng As Range, rng1 As Range
Set rng = Range(Cells(2, "C"), Cells(Rows.Count, "C").End(xlUp))
For Each cell In rng
If cell.Value < 26 Then
If rng1 Is Nothing Then
Set rng1 = cell
Else
Set rng1 = Union(rng1, cell)
End If
End If
Next
If Not rng1 Is Nothing Then
rng1.EntireRow.Delete
End If
End Sub
or
Sub DeleteRows()
Dim rng As Range, rng1 As Range
Range("C1").CurrentRegion.AutoFilter _
Field:=3, Criteria1:="<26", Operator:=xlAnd
Set rng = Intersect(ActiveSheet.AutoFilter.Range, Columns(3))
Set rng = rng.Offset(1, 0).Resize(rng.Rows.Count - 1, 1)
On Error Resume Next
Set rng1 = rng.SpecialCells(xlVisible)
On Error GoTo 0
If Not rng1 Is Nothing Then
rng1.EntireRow.Delete
End If
ActiveSheet.ShowAllData
Range("C1").CurrentRegion.AutoFilter
End Sub
Should do it.
--
Regards,
Tom Ogilvy
"DKY" wrote in message
...
Here's what I got, and needless to say attributing to my extreme lac
of
experience its not working. any suggestions?
Dim rng As Range, sStr As String, i As Long
Set rng = Cells(A, 65536).End(xlToLeft)
For i = rng.Row To 1 Step -1
sStr = LCase(Cells(1, i).Value)
If sStr < "26" Then
Cells(A, i).EntireRow.Delete
End If
Next
--
DKY
------------------------------------------------------------------------
DKY's Profile:
http://www.excelforum.com/member.php...o&userid=14515
View this thread
http://www.excelforum.com/showthread...hreadid=263154
--
DK
-----------------------------------------------------------------------
DKY's Profile:
http://www.excelforum.com/member.php...fo&userid=1451
View this thread:
http://www.excelforum.com/showthread.php?threadid=26315