Question : Worksheet_Change

I have a worksheet that has a named range in it called "Col_M".  It is on a open unlocked, unprotected sheet.  The cells in the range "Col_M" have formulas in them and I want to use the WorkSheet_Change process to prevent the change of the cells in the range, instead of sheet protect, lock unlock.... (long story) but I have to use something other then the standard sheet protection method.

Is there a way to use WorkSheet_Change to montior this range, and if a user trys to change a cell value in that range to stop it, alert no chg is allowed and prevent the change?

Col_M is a dynamic range so rows are being added and deleted all the time and it should not matter that rows are added or taken away.  This process should not care of rows are added or deleted from Col_M, and it should allow for that, just no cell edits for the cells in the Col_M range.

Can this even be done?  Please advise and thanks. -R-

Answer : Worksheet_Change

Hello R,

this one should work even better: in the previous version, the user could select more than one cell and delete the formulas. The version attached now only allows the insertion or deletion of *complete* rows or columns. All other cell manipulation on the range "col_M" will not be allowed.

cheers, teylyn
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("col_M")) Is Nothing Then
    Application.EnableEvents = False
    If Target.Rows.Count = Range("A1", Cells(Rows.Count, "A")).Rows.Count Then
        Application.EnableEvents = True
        Exit Sub
    End If
    If Target.Columns.Count = Range("A1", Cells(1, Columns.Count)).Columns.Count Then
        Application.EnableEvents = True
        Exit Sub
    End If
    Application.Undo
    MsgBox "You can only insert or delete whole columns or rows, not change cells."
    Application.EnableEvents = True
End If
End Sub
Random Solutions  
 
programming4us programming4us