Re: delete rows
- From: "Bob Phillips" <bob.NGs@xxxxxxxxxxxxx>
- Date: Thu, 5 Oct 2006 16:11:05 +0100
Public Sub Tester02()
Dim Rng As Range, Rng1 As Range
For i = 10000 To 7 Step -1
If IsError(Cells(i, "B")) Then
If Rng1 Is Nothing Then
Set Rng1 = Rows(i)
Else
Set Rng1 = Union(Rng1, Rows(i))
End If
End If
Next i
If Not Rng1 Is Nothing Then Rng1.Delete
End Sub
I think Sandy's doesn't work because he is going top-down, and the pointers
get out of sync, which is why I went bottom up.
--
HTH
Bob Phillips
(replace somewhere in email address with gmail if mailing direct)
"massi" <massi@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:DCBED91C-1BD9-47DE-9F12-9E68D6F145CD@xxxxxxxxxxxxxxxx
I have tried both of the methods that you have suggested but unfortuantelyno
one works.not
The one from Bob returns me Compile Error: Syntax error and it gets stuck
while the one.
and yours it works only partially, meaning that it deletes some rows but
all and it deletes also the ones with the relevant information i want tokeep.
has
any idea why?
thank you
"Sandy" wrote:
This one will work too...
Sub DeleteRow()
Dim MyCell As Range
On Error Resume Next
For Each MyCell In Range("B1:B10000")
If CVErr(MyCell) = CVErr(xlErrNA) Then
MyCell.EntireRow.Delete
End If
DoEvents
Next MyCell
End Sub
Sandy
massi wrote:
Hi,
I need a macro that check the values of a column (let's say B) which
deletelinks to another ***. in case the cell is equal to "#N/A" I want to
thethe whole row.
I have a macro that works fine if the cell is empty (see below) :
'=======================
Public Sub Tester02()
Dim Rng As Range, Rng1 As Range
Set Rng = Range("b7:b10000") '<<====== from b7 to b10000
On Error Resume Next
Set Rng1 = Intersect(Rng, _
Columns("B:B").SpecialCells(xlBlanks))
On Error GoTo 0
If Not Rng1 Is Nothing Then Rng1.EntireRow.Delete
End Sub
'<<=======================
I have tried this one below but it doesn't work.
'=======================
Public Sub Delete_empty()
If IsError(.Cells(Lrow, "b").Value) Then
'Do nothing, This avoid a error if there is a error in
..Rows(Lrow).Deletecell
ElseIf .Cells(Lrow, "b").Value = "#N/A" Then
Column A,'This will delete each row with the Value "ron" in
case sensitive.
End If
End Sub
'<<=======================
any suggestion?
thankx
.
- Follow-Ups:
- Re: delete rows
- From: Sandy
- Re: delete rows
- References:
- Re: delete rows
- From: Sandy
- Re: delete rows
- From: massi
- Re: delete rows
- Prev by Date: Re: How to get known by which application Excel was launched?
- Next by Date: Modelling Object Models
- Previous by thread: Re: delete rows
- Next by thread: Re: delete rows
- Index(es):
Loading