ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   prevent a special cell from being deleted (https://www.excelbanter.com/excel-programming/365570-prevent-special-cell-being-deleted.html)

jagexcel[_4_]

prevent a special cell from being deleted
 

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.


--
jagexcel
------------------------------------------------------------------------
jagexcel's Profile: http://www.excelforum.com/member.php...o&userid=35657
View this thread: http://www.excelforum.com/showthread...hreadid=556248


Mark Driscol[_2_]

prevent a special cell from being deleted
 
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


jagexcel wrote:
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.


--
jagexcel
------------------------------------------------------------------------
jagexcel's Profile: http://www.excelforum.com/member.php...o&userid=35657
View this thread: http://www.excelforum.com/showthread...hreadid=556248




All times are GMT +1. The time now is 07:35 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com