Reputation: 25
I have a worksheet with protected cells. There's an 'add row' button and I need a 'delete row' button. HOWEVER, I only want the user to be able to delete the row if it is within a named range.
ActiveSheet.Unprotect Password:="password"
If "selected row" within Range("ProjectList") Then
Row.EntireRow.Delete Shift:=xlUp
End If
ActiveSheet.Protect Password:="password"
Upvotes: 1
Views: 1719
Reputation: 166885
You can use Intersect to check this:
If Not Application.Intersect(Selection.EntireRow, Range("ProjectList")) Is Nothing Then
Selection.EntireRow.Delete Shift:=xlUp
End If
Upvotes: 7