leezac
asked on
Delete criteria change to code
Is there a way to add to the delete portion of the code an exception "not to delete the row on the Accounts tab where the word "Manual" is in column B".
somehow this this row "If Not (IsEmpty(Sheets("Compare") .Cells(obj Cell.Row, "AP"))) Then
Sheets("Accounts").Rows(ln gRow).Enti reRow.Dele te
Thanks in advance.
__________________________ __________ __________ __________ ________
Sub DeleteMissingAccounts()
Dim lngRow As Long
Dim objCell As Range
Dim objRange As Range
On Error Resume Next
Application.ScreenUpdating = False
Set objRange = Range(Sheets("Compare").[c 3], Sheets("Compare").Cells(Sh eets("Comp are").Cell s.Rows.Cou nt, "C").End(xlUp))
If Not (objRange Is Nothing) Then
Sheets("Accounts").Select
For lngRow = Cells(Cells.Rows.Count, 1).End(xlUp).Row To 2& Step -1&
Set objCell = Nothing
Set objCell = objRange.Find(What:=Cells( lngRow, "A"))
If Not (objCell Is Nothing) Then
If Not (IsEmpty(Sheets("Compare") .Cells(obj Cell.Row, "AP"))) Then
Sheets("Accounts").Rows(ln gRow).Enti reRow.Dele te
End If
End If
Next lngRow
End If ' If Not (objRange Is Nothing) Then
somehow this this row "If Not (IsEmpty(Sheets("Compare")
Sheets("Accounts").Rows(ln
Thanks in advance.
__________________________
Sub DeleteMissingAccounts()
Dim lngRow As Long
Dim objCell As Range
Dim objRange As Range
On Error Resume Next
Application.ScreenUpdating
Set objRange = Range(Sheets("Compare").[c
If Not (objRange Is Nothing) Then
Sheets("Accounts").Select
For lngRow = Cells(Cells.Rows.Count, 1).End(xlUp).Row To 2& Step -1&
Set objCell = Nothing
Set objCell = objRange.Find(What:=Cells(
If Not (objCell Is Nothing) Then
If Not (IsEmpty(Sheets("Compare")
Sheets("Accounts").Rows(ln
End If
End If
Next lngRow
End If ' If Not (objRange Is Nothing) Then
ASKER
Thanks, I just thought - can I put <> "Manual" or "Duplicate")
in this line?
If (Sheets("Compare").Cells(o bjCell.Row , "B") <> "Manual")
in this line?
If (Sheets("Compare").Cells(o
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
als315 that does not work
If "Manual" is in Column B of the Accounts tab (has nothing to do with the Compare tab) I just want to be able to keep it and not delete it when the other rows are deleted.
If "Manual" is in Column B of the Accounts tab (has nothing to do with the Compare tab) I just want to be able to keep it and not delete it when the other rows are deleted.
ASKER
These were answers that would work, but I need to repost the question.
If Not (IsEmpty(Sheets("Compare")
to:
Open in new window