+ Reply to Thread
Results 1 to 10 of 10

Timestamp Doesn't Work When Workbook Is Shared

Hybrid View

  1. #1
    Forum Expert GeneralDisarray's Avatar
    Join Date
    09-15-2011
    Location
    Pittsburgh, PA, USA
    MS-Off Ver
    Windows Excel 2016
    Posts
    1,416

    Re: Timestamp Doesn't Work When Workbook Is Shared

    Ok, I have a few suggestions.

    First, the code needed to have some alterations to handle changes to lots of rows at once. Instead of just checking for the "Target" column, find the intersection of "Target" and Column B. This is more precisely what you want to do (I think).

    Also, don't hard-code values! I used some named constants at the top of the module (where they will always be easy to find) to allow for easy editing. This is a good habit to get into.

    When you use a worksheet change event (that causes another change to be made) turn off events! Otherwise it will want to run again... it's just sloppy. You can turn the events back on prior to End Sub.

    Also, the way your sheet was set up people could alter the tab names - like "Days B". To avoid having that mess up your code, use code names which you can only alter in the VBA editor (you'll see what i mean if you view the object explorer on this workbook).

    :D

    Please have a look at the attachment.


    CODE FOR CHANGE EVENT (I put this in "Days B" - try it out):

    Option Explicit
    
    Const gunIdColumnNumber = 2
    Const timRowOffsetFromGunIdColumn = 1
    
    
    Private Sub Worksheet_Change(ByVal Target As Range)
    
    Dim myRange As Range, myCell As Range
    Set myRange = Intersect(w_DaysB.Cells(1, gunIdColumnNumber).EntireColumn, Target)
    
    Application.EnableEvents = False
    If Not myRange Is Nothing Then
    w_DaysB.Unprotect ("example")
        For Each myCell In myRange
            If myCell.Value <> "" Then
                myCell.Offset(0, timRowOffsetFromGunIdColumn) = Time
            Else
                myCell.Offset(0, timRowOffsetFromGunIdColumn).ClearContents
            End If
        Next myCell
    End If
    w_DaysB.Protect ("example")
    Application.EnableEvents = True
    End Sub
    Attached Files Attached Files
    Remember, saying thanks only takes a second or two. Click the star icon(*) below the post you liked, to give some Rep if you think an answer deserves it.

    Please,mark your thread [SOLVED] if you received your answer.

+ 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] date & Timestamp for row on Protected & Shared workbook
    By Webbers in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-29-2013, 10:42 AM
  2. [SOLVED] Macro work in personal workbook, doesn't work in other workbooks
    By Centexcel in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 09-30-2013, 11:47 AM
  3. Replies: 0
    Last Post: 09-18-2012, 11:24 AM
  4. Macro doesn't work when shared
    By rasmus1166 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-10-2011, 10:00 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

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