+ Reply to Thread
Results 1 to 5 of 5

VBA that enters TIMESTAMP after data entry, then locks it

  1. #1
    Registered User
    Join Date
    10-29-2013
    Location
    Little Rock, AR
    MS-Off Ver
    Excel 2007
    Posts
    2

    VBA that enters TIMESTAMP after data entry, then locks it

    I have a number of checks that are conducted with a user entering a 1=yes, 0=no in a number of cells when these checks are completed. How can I have a timestamp entered to the column left of entry and have it locked afterwards. I keep getting an error message when I lock the worksheet. File is attached with sample - no code.
    Attached Files Attached Files

  2. #2
    Forum Contributor
    Join Date
    11-15-2012
    Location
    Buffalo, NY
    MS-Off Ver
    Office 365
    Posts
    286

    Re: VBA that enters TIMESTAMP after data entry, then locks it

    Take a look at this sample.

    The trick, I think, is to UNLOCK the places where the initial "1" can be put, and then to protect the whole sheet.

    You'll still need VBA to unlock the sheet before it makes the changes.

    See what you think,

    Tony
    Attached Files Attached Files

  3. #3
    Registered User
    Join Date
    10-29-2013
    Location
    Little Rock, AR
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: VBA that enters TIMESTAMP after data entry, then locks it

    Thanks for the help. Below is an example of what code I was using. I attached another file showing how I want it to work - but I just need the time-stamped locked afterwards. Thanks.


    Private Sub Worksheet_Change(ByVal Target As Excel.Range)
    With Target
    If .Count > 1 Then Exit Sub
    If Not Intersect(Range("B5"), .Cells) Is Nothing Then
    Application.EnableEvents = False
    If IsEmpty(.Value) Then
    .Offset(0, -1).ClearContents
    Else
    With .Offset(0, -1)
    .NumberFormat = "hh:mm:ss"
    .Value = Now
    End With
    End If
    Application.EnableEvents = True
    End If
    End With
    Attached Files Attached Files

  4. #4
    Forum Contributor
    Join Date
    11-15-2012
    Location
    Buffalo, NY
    MS-Off Ver
    Office 365
    Posts
    286

    Re: VBA that enters TIMESTAMP after data entry, then locks it

    A couple of quick questions.

    The only cell you test for is B5. Are ALL of your test going to use B5 as the response point? If so, how will you know which test is being signed off? (The only cell you modify is "A5"!)

    You need to Unprotect the worksheet in order to make the changes (a locked cell is only protected when the worksheet is protected), and then re-protect it when you are done (see the lines in my code).

    As I mentioned, I've added a column so that you can get a description of the step, however, if you don't want that, then adjust the column references accordingly.

    If you don't want to lock the sign-off cell (is it of any use if people can change it?) then simply comment out the
    Please Login or Register  to view this content.
    line.

    Lastly, try and get into the habit of using .Formula rather than .Value when setting the contents of a cell. It's the way Bill and Steve prefer it!

    Please Login or Register  to view this content.
    HTH

    Tony

  5. #5
    Forum Contributor
    Join Date
    11-15-2012
    Location
    Buffalo, NY
    MS-Off Ver
    Office 365
    Posts
    286

    Re: VBA that enters TIMESTAMP after data entry, then locks it

    Oh, and I fogot about your number format request. You've got the right code - it's just not in my example

+ 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. [SOLVED] UserForm Enters Final Data Into First Row
    By LoneWolf3574 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-01-2012, 07:46 PM
  2. VBA timestamp that locks unlocked cells in range upon entry
    By twhite in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-13-2012, 12:42 AM
  3. Splitting Data with Enters
    By Stiffler in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-04-2010, 08:25 AM
  4. [SOLVED] Excel formula timestamp for a data entry of a referenced cell
    By jmasaki in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 07-02-2006, 09:25 PM
  5. Replies: 1
    Last Post: 11-02-2005, 06:17 PM

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