+ Reply to Thread
Results 1 to 3 of 3

timestamp macro h:mm:ss format error message

  1. #1
    Registered User
    Join Date
    02-15-2013
    Location
    Ellsivill, IL
    MS-Off Ver
    Excel 2011 for MAC
    Posts
    2

    timestamp macro h:mm:ss format error message

    Although the profile information indicates I am using Excel 2011 for MAC, that is what I use at home. I am using Excel 2010 at work and that is where I am having problems. I created a macro to enter a timestamp in a cell in the h:mm:ss format. I also created shortcut key CNTRL+t

    Here is the macro

    Sub timestamp()

    Let ActiveCell.Value = Time
    Let ActiveCell.NumberFormat = "h:mm:ss"

    End Sub


    The macro works just fine until I protect the sheet. Then I get an error message when I run the macro.
    Run-time error '1004':
    Unable to set the NumberFormat property of the Range class.

    Please help me debug this error.

    Thanks!
    Last edited by drsuis; 02-15-2013 at 01:56 PM.

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: timestamp macro h:mm:ss format error message

    Mmmm,

    It's not an error since you're trying to do something to a sheet which you have decided should be protected. I actually get a message which mentions the Run Time 1004 error but then goes on to say the sheet is protected - which is a large clue! I don't see the 'NumberFormat' comment in the message box.

    However just preface your macro with ActiveSheet.Unprotect and end it with ActiveSheet.Protect
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Registered User
    Join Date
    02-15-2013
    Location
    Ellsivill, IL
    MS-Off Ver
    Excel 2011 for MAC
    Posts
    2

    Re: timestamp macro h:mm:ss format error message

    Thanks! Did the trick

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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