Rick Rothstein posted this. Can you expand your help with a different sitation

scockster

New Member
Joined
Feb 15, 2019
Messages
17
Mr. Rothstein posted an answer to this question

I enter data in A2, B2, C2, D2.
When i enter data in E2 i would like that A2, B2, C2 and D2 will be locked.
When i remove the data from E2 the cells will unlock again.

And this for every row. So also for A3, B3, C3 and D3 and so on.


The example i found will lock the entire range.

Can someone help me with this?

Your response WAS

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Columns("A:D")) Is Nothing And Target.CountLarge > 0 Then
If Len(
Cells(Target.Row, "E").Value) Then
MsgBox "You cannot change values in Columns A:D if cell in Column E has a value in it!" & _
vbLf & vbLf & "The previous cell value will now be restored.", vbExclamation
Application.EnableEvents = False
Application.Undo
Application.EnableEvents = True
End If
End If
End Sub


WORKED GREAT BUT......


What if I need to lock a range of cells after input in the same range. To be clear, For the range C5:H5, I want to lock the remaining cells in that range
if there is any data input. I already have data validation going on in these cells because they contain drop-down menues. If I delete that data the cells in that range will unlock. I would like to do this for about 15-20 different ranges of cells. I hope it
was alright to mention your username Mr. Rothstein since it was such a great response to the initial question. Hope you can help.
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.

Forum statistics

Threads
1,214,638
Messages
6,120,674
Members
448,977
Latest member
moonlight6

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