Prevent update/entries on cell range based on sheet/tab name?

FGaxha

Board Regular
Joined
Jan 10, 2023
Messages
221
Office Version
  1. 365
Platform
  1. Windows
Hi,
VBA Code: How to prevent update/entries on cell range "C33 :F52" if Tab Name is "MASTER" else ok
 
You stated that

In which case none of those selection will make a difference, but you now say

In which case the sheet is protected.

After unlocking all cells, select range C33:F52 & make them locked, then no one can enter data into them.
Well,
Sheet is protected form "Insert Column ,Insert Rows, Delete Column, Delete Rows.
Sheet is unprotected for entering data in any cells, so then it is involved VBA Code to keep clear range "C33:F52": only if Sheet/Tab name is "MASTER"
VBA:
Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
If Target.Cells.Count > 1 Then Exit Sub
If Not Intersect(Target, Range("C33:F52")) Is Nothing Then
If ActiveSheet.Name = "MASTER" Then
cng = Target.Value
Application.Undo
Target.Value = Target.Value
Else
End If
End If
Application.EnableEvents = True
End Sub
-----------------------------------------------------------
Also there is second macro to prevent tab/sheet changing name: It keeps Tab name MASTER:

VBA
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Sheet1.Name <> "MASTER" Then
Sheet1.Name = "MASTER"

End If
End Sub
 
Upvote 0

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.

Forum statistics

Threads
1,215,059
Messages
6,122,916
Members
449,093
Latest member
dbomb1414

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top