Locing collums

Medinukas

New Member
Joined
Apr 18, 2018
Messages
11
Hello I desperetly need help work work.
I need to lock a column if another column has data entered and vise versa
Example I have a column A and B if enter any data in column A then I can't enter any data in column B and vise versa Plz help someone?
 
If you use that approach, you don't need to unlock or protect the sheet. Follow the steps I described in Post #2 to paste this macro.
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Intersect(Target, Range("A:A,B:B")) Is Nothing Then Exit Sub
    Select Case Target.Column
        Case Is = 1
            If Target = Target.Offset(0, 1) Then
                MsgBox ("You cannot enter a duplicate value.")
            End If
        Case Is = 2
            If Target = Target.Offset(0, -1) Then
                MsgBox ("You cannot enter a duplicate value.")
            End If
    End Select
End Sub
 
Upvote 0

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.

Forum statistics

Threads
1,215,059
Messages
6,122,917
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