prevent a special cell from being deleted

J

jagexcel

The cell has the content "Do Not Delete"

How do I write an If statement to prevent this cell from being deleted
by a macro that deletes a row?

Thanks.
 
M

Mark Driscol

Maybe something like this will work.

Option Explicit

Sub DeleteRow()

Dim row As Range
Dim c As Range

For Each row In Selection.EntireRow
Set c = row.Find(What:="Do Not Delete")
If c Is Nothing Then
row.Delete
End If
Next row

End Sub


Mark
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top