+ Reply to Thread
Results 1 to 8 of 8

lock after edit each cell in column L to Q and stamp date and username in column R and S

  1. #1
    Registered User
    Join Date
    11-14-2018
    Location
    Selangor, Malaysia
    MS-Off Ver
    Office 2016
    Posts
    50

    lock after edit each cell in column L to Q and stamp date and username in column R and S

    Hi everyone. I need help with my VBA below.

    Im a newbie in VBA therefore not sure how to go about it.I have a code.

    The code allows:-

    1.Multiple User to key in data in column L To Q in sheet3 named as master
    2. Each changes in the cell from L to Q a pop up msg box box will confirm data input and locked the cells


    Issue now:

    1. How do I intergrate in the same work Worksheet_Change function to have a date stamp in column R and username stamp at column S on who edited the column and the stamp should be locked too so no one can change the username and date stamp.

    Below is the lock cell after each input code:

    Please Login or Register  to view this content.
    # Private Sub Worksheet_Change(ByVal Target As Range)

    Dim KeyCells As Range
    Set KeyCells = Range("L1:Q99999")

    ActiveSheet.Unprotect Password:="lina123"
    For Each KeyCells In Target
    If KeyCells.Value <> "" Then
    check = MsgBox("Is this entry correct? This cell cannot be edited after entering a value.", vbYesNo, "Cell Lock Notification")
    If check = vbYes Then
    KeyCells.Locked = True
    Else
    KeyCells.Value = ""

    End If
    End If
    Next KeyCells
    ActiveSheet.Protect Password:="lina123"
    End Sub#
    Please Login or Register  to view this content.

    I have a code for the stamp but not sure how to combine it. Stamp code as below:-


    Please Login or Register  to view this content.
    # Private Sub Worksheet_Change(ByVal Target As Range)

    Dim KeyCells As Range
    Dim tgRow As Long
    Set KeyCells = Range("L1:Q99999")


    'If any data is entered in columns L:Q Colum R will record the date and time, and Colum S will record the
    'windows username.

    If Not Application.Intersect(KeyCells, Range(Target.Address)) Is Nothing Then

    tgRow = Target.Row
    ActiveSheet.Unprotect Password:="lina123"
    If Application.CountA(Target) <> 0 And _
    Application.CountA(Range("R" & tgRow & ":S" & tgRow)) = 0 Then
    Range("R" & tgRow).Value = Date + Time
    Range("S" & tgRow).Value = Environ("username")
    ActiveSheet.Protect Password:="lina123"
    End If

    End If
    End Sub #
    Please Login or Register  to view this content.
    Last edited by Norlina Deli; 01-08-2019 at 02:26 AM.

  2. #2
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: lock after edit each cell in column L to Q and stamp date and username in column R and

    Windows 10 is NOT an office version!

    All you need to do is add the date stamp and username if the user answers YES
    ---
    Hans
    "IT" Always crosses your path!
    May the (vba) code be with you... if it isn't; start debugging!
    If you like my answer, Click the * below to say thank-you

  3. #3
    Registered User
    Join Date
    11-14-2018
    Location
    Selangor, Malaysia
    MS-Off Ver
    Office 2016
    Posts
    50

    Re: lock after edit each cell in column L to Q and stamp date and username in column R and

    Hi Keebellah. Thanks you for pointing that out sorry its actually office 2016. Do you mind showing me how I can combine the vba
    Not sure how to do so.

  4. #4
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,883

    Re: lock after edit each cell in column L to Q and stamp date and username in column R and

    Before we go any further, please read the forum rules about code tags and then add code tags to your opening post following the instructions on the rules page. Thanks!
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  5. #5
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: lock after edit each cell in column L to Q and stamp date and username in column R and

    You wrote the code you have,
    You knwo which row you're on so just use that value to add the necessary update.
    It's easy to tell you but if you figure it out yourself you will remember it better
    VBA is a lot of perspiration, time and imagination.
    If you still can't get it to work, then I'll help you out

  6. #6
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: lock after edit each cell in column L to Q and stamp date and username in column R and

    Maybe something like this?
    I reduced the range but you can change that yourself
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    11-14-2018
    Location
    Selangor, Malaysia
    MS-Off Ver
    Office 2016
    Posts
    50

    Re: lock after edit each cell in column L to Q and stamp date and username in column R and

    Hi Keebellah sorry for the late reply.Thank you so much for helping me it works like a charm.

  8. #8
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: lock after edit each cell in column L to Q and stamp date and username in column R and

    Glad to have been able to help
    You're welcome

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. How do I update a cell in column C with a date stamp anytime cells A,B,D,E,F
    By nikolastrum in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-30-2014, 01:19 PM
  2. [SOLVED] Date Stamp one column based on set data in another column
    By HACCStaff in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 04-10-2013, 02:21 AM
  3. Replies: 4
    Last Post: 11-11-2012, 02:52 PM
  4. Date stamp on column A when data is entered in either column C to Z
    By Kanook22 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-06-2012, 01:49 PM
  5. Insert Date/Time stamp in cell after edit
    By anonymust in forum Excel General
    Replies: 2
    Last Post: 07-18-2012, 06:03 PM
  6. Auto Date Stamp Column A when data in Column B
    By medihx in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-31-2011, 06:56 PM
  7. Replies: 1
    Last Post: 04-24-2006, 05:35 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1