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
Bookmarks