+ Reply to Thread
Results 1 to 8 of 8

Timestamp Macro

Hybrid View

  1. #1
    Registered User
    Join Date
    05-14-2020
    Location
    Washington, D.C
    MS-Off Ver
    2016
    Posts
    8

    Timestamp Macro

    I tried a timestamp macro and keep getting this error when I update a cell:

    Run-time error '1004'
    Application-defined or object-defined error"

    The Macro I am using is:

    Private Sub Worksheet_Change(ByVal Target As Range)
      If Target.Column < 26 And Target.Count = 1 Then Cells(Target.Row, 26) = Now
    End Sub
    Column 26 is where the timestamp is located.
    What do I need to do to fix this?

    Moderator Comment: Please use Code Tags. I have added them today. Review the forum rules you agreed to when you joined.
    Attached Files Attached Files
    Last edited by michael.d.g; 05-18-2020 at 10:40 AM. Reason: Addind attachment example

  2. #2
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Cool Try this ‼


    If Target.CountLarge = 1 Then If Target.Column < 26 Then Cells(Target.Row, 26) = Now

    ► Do you like it ? ► So thanks to click on bottom left star icon « Add Reputation » !

  3. #3
    Registered User
    Join Date
    05-14-2020
    Location
    Washington, D.C
    MS-Off Ver
    2016
    Posts
    8

    Re: Try this ‼

    Thank you for your response. I am however getting the same error.

    This is what my macro looks like.


    Private Sub Worksheet_Change(ByVal Target As Range)
        If Target.CountLarge = 1 Then If Target.Column < 26 Then Cells(Target.Row, 26) = Now
    End Sub

  4. #4
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Re: Timestamp Macro


    How unlucky you are as it well works on my side with your attachment as it is …

  5. #5
    Registered User
    Join Date
    05-14-2020
    Location
    Washington, D.C
    MS-Off Ver
    2016
    Posts
    8

    Re: Timestamp Macro

    I appreciate your feedback.

    I got it to work if the worksheet was not protected. Is there a way I can use the vba if I have "Protect Sheet" enabled?
    For some reason the VBA code will not work that way.

    Is there something special I have to put in the VBA code so that it will work with Protect Sheet and not give me the

    Run-time error '1004':
    Application-defined or object-defined error
    Last edited by michael.d.g; 05-18-2020 at 04:09 PM.

  6. #6
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Re: Timestamp Macro


    You can use Worksheet.Unprotect method before to update the cell then Protect back the sheet just after …

  7. #7
    Registered User
    Join Date
    05-14-2020
    Location
    Washington, D.C
    MS-Off Ver
    2016
    Posts
    8

    Re: Timestamp Macro

    Is the Worksheet.Unprotect method something I put in the VBA? Is it a separate macro? What is the code I should use?

    Thanks in advance.

  8. #8
    Registered User
    Join Date
    05-14-2020
    Location
    Washington, D.C
    MS-Off Ver
    2016
    Posts
    8

    Re: Timestamp Macro

    NEED HELP!

    What I am trying to do in a workbook in which each Worksheet is password protected do the following:
    Any edits to Columns A-Q, a timestamp will appear in Column Z.
    The Private Sub below only seems to work when the Worksheet was not password protected.
    I would like to insert the code, password protect it and then when a user edits columns A-Q, a timestamp appears in Column Z.

    Below is the code I was using which did not work.
    Thanks in advance.


    Workbooks("Excel Forum example").Protect Password:="a"

    Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.CountLarge = 1 Then If Target.Column < 26 Then Cells(Target.Row, 26) = Now
    End Sub


    .
    Last edited by michael.d.g; 05-19-2020 at 02:53 PM.

+ 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. Macro for username and timestamp
    By jojofc88 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-10-2019, 01:50 PM
  2. Insert Timestamp on same row that macro is run
    By marcosis in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-18-2017, 11:06 AM
  3. Replies: 2
    Last Post: 11-09-2016, 02:23 PM
  4. [SOLVED] Timestamp Macro Error
    By Taiter in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 03-13-2014, 08:09 AM
  5. When a timestamp doesn't behave as a timestamp
    By mredekopp in forum Excel General
    Replies: 3
    Last Post: 03-07-2011, 03:39 PM
  6. Timestamp macro questions
    By nugundam93 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-07-2007, 04:57 PM
  7. [SOLVED] Timestamp Macro
    By alexfthe in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 03-12-2006, 07:45 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