If a cell contains the word "Completed", then return the date/time when it changed.

awkwardjae

New Member
Joined
Jul 24, 2024
Messages
1
Office Version
  1. 365
Platform
  1. Windows
Hi I have a excel form (mostly use it through sharepoint) where people submit a google form and request tasks for my team to complete. This google form autofills a row each time a request is submitted with different information not limited to submission date, ID, Name, Request etc. We have a status column (column S) in excel that contains one of "Not Started" default when request submitted, "In Progress" when someone enters their initial in "Prep" Column, "Not Tested" which we manually change if no do the request and "Completed" when we sign our initial in the "Done" Column AND "Prep" Column. All of this are automatically triggered (with exception of Not Tested). What I would like to include is a seperate column due to demand and audit reasons that says "Completed On" (column T) which essentially gets updated with the date and time that the Status column says "Completed".
Few things to note, would like this to apply automatically as requests are entered and status changes.
Currently we are on row 2751
If it cannot be applied retroactively that is fine, just for future requests
If possible if the status changes from Completed to another (due to someone accidentally signing) the completed on becomes blank.

I have tried:
Private Sub Worksheet_Change(ByVal Target As Range)

Dim rng As Range
Dim cell As Range

' See if any updates to specified range
Set rng = Intersect(Range("S2:S150000"), Target)

' Exit sub if no changes to watched range
If rng Is Nothing Then Exit Sub

' Loop through changed cells
Application.EnableEvents = False
For Each cell In rng
' See if cell is set to "Completed"
If cell.Value = "Completed" Then
' Add date stamp to column T of same row
cell.Offset(0, 1).Value = Now
End If
Next cell
Application.EnableEvents = True

End Sub

But does not seem to trigger the date showing.
Any help, advice, direction is appreciated. Thank you
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
Upon testing, this seems to work as expected. Do you have any other VBA code in the workbook? Either way, here is the code with the update to clear the cell if col S does not equal "Completed".

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)

Dim rng As Range
Dim cell As Range

' See if any updates to specified range
Set rng = Intersect(Range("S2:S150000"), Target)

' Exit sub if no changes to watched range
If rng Is Nothing Then Exit Sub

' Loop through changed cells
Application.EnableEvents = False
For Each cell In rng
    ' See if cell is set to "Completed"
    If cell.Value = "Completed" Then
        ' Add date stamp to column T of same row
        cell.Offset(0, 1).Value = Now
    Else
        cell.Offset(0, 1).Value = ""
    End If
Next cell
Application.EnableEvents = True

End Sub
 
Upvote 0

Forum statistics

Threads
1,220,965
Messages
6,157,119
Members
451,398
Latest member
rjsteward

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top