Results 1 to 1 of 1

Freeze Time Stamp upon clicking command button

Threaded View

  1. #1
    Registered User
    Join Date
    07-04-2016
    Location
    Columbus,OH
    MS-Off Ver
    2013
    Posts
    1

    Freeze Time Stamp upon clicking command button

    Hello everyone

    I am working on a code whereby I click on my "enter time" command button and then it displays current time in the first column then I hit enter time in the second column again and it stops the clock and shows me the time as well and then shows elapsed time in the third column . However, I want to lock the cells in the first two columns and password protect them.Additionally, I want to clear the first two columns when the clear button is clicked. Could I get some help please since I am totally new to VBA? Thanks

    My code is as following

    Private Sub CommandButton1_Click()
    Worksheets("Sheet1").Activate
    ActiveCell.Value = Format(Now, "mm/dd/yy hh-mm")
    
    
    End Sub
    
    Private Sub Worksheet_Change(ByVal Target As Range)
    
    Dim MyRange As Range
    
        Set MyRange = Intersect(Range("A2:A5,B2:B5"), Target)
        If Not MyRange Is Nothing Then
            Sheets("Sheet1").Unprotect Password:="admin"
            MyRange.Locked = True
            Sheets("Sheet1").Protect Password:="admin"
        End If
    
    End Sub
    
    
    Sub Clear_Command()
    Worksheets("Sheet1").Activate
    Sheets("Sheet1").Unprotect Password:="admin"
    Range("A2:A5,B2:B5").ClearContents
    
    End Sub
    
    Sub EnterCurrentTime()
    '
    ' EnterCurrentTime Macro
    ' This macro enters the current time into the active cell
    '
    
    '
    
    Worksheets("Sheet1").Activate
    Sheets("Sheet1").Unprotect Password:="admin"
    ActiveCell.Value = Now()
    Sheets("Sheet1").Protect Password:="admin"
        
    
        
    End Sub
    Moderator's note: Please take the time to review our rules. There aren't many, and they are all important. Rule #3 requires code tags. I have added them for you this time because you are a new member. --6StringJazzer

    Untitled.png
    Last edited by 6StringJazzer; 07-04-2016 at 08:56 AM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Clicking the command button more than twice
    By Templemind in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 09-06-2014, 08:38 AM
  2. [SOLVED] Freeze time stamp after data is entered into a particular cell
    By awsachsen in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 09-03-2014, 02:29 PM
  3. Posting time stamp and username using command button
    By mcav16 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-23-2014, 04:08 PM
  4. Freeze Command Button On Screen?
    By DonG in forum Excel General
    Replies: 3
    Last Post: 10-27-2011, 07:02 PM
  5. Double Clicking a Command Button
    By NewExcelUser in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-09-2007, 01:37 AM
  6. Command Button Date/Time Stamp
    By sky in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-10-2006, 08:10 PM
  7. Replies: 0
    Last Post: 06-27-2005, 06:05 AM

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