want to lock cells in a row in attendance tracker

sunilbsrv2k

Board Regular
Joined
May 25, 2018
Messages
73
Hi All,

I have a question in Excel/VBA.

I am creating an Attendance tracker for about 200 team members; in which each row corresponding to a team member displays their attendance for the entire month.

There are 3 types of leaves: CL, SL and EL.

The last 3 columns of the table show the total number of leaves taken by the member in each type mentioned above.

Now, the question is, if a person crosses 2 in CL, then that entire row should be disabled from entering another CL; however, it should still allow me to update SL and EL in all other cells.


Could any of you help me on this

Thanks,
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
Hi All,

I might have complicated my question.

Let me simplify this in one line:

I have a row in which if I enter CL 2 times, then it should not allow me to enter CL (only) again in the specified range.

Thanks
 
Upvote 0
Let's start with the following, if I understood your idea.
Put the following code in the events of your sheet.


Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    Dim r As Range, c As Range
    Set r = Range("A1:D10")
    On Error GoTo appEnable
    If Not Intersect(Target, r) Is Nothing Then
        If Target.Count > r.Count Then Exit Sub
        Application.EnableEvents = False
        For Each c In Target
            If UCase(c.Value) = "CL" Then
                wcount = WorksheetFunction.CountIf(r, c.Value)
                If wcount > 1 Then
                    MsgBox "not allow"
                    c.Value = ""
                End If
            End If
        Next
        Application.EnableEvents = True
    End If
appEnable:
    Application.EnableEvents = True
End Sub

SHEET EVENT
Right click the tab of the sheet you want this to work, select view code and paste the code into the window that opens up.
 
Upvote 0

Forum statistics

Threads
1,223,904
Messages
6,175,295
Members
452,633
Latest member
DougMo

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