Thanks so much Cliff. :)
I still need this to trigger the event to Copy the data in the corresponding row in column G and I and paste it in a specific Teams Chat.
Need to also figure out how to run the VB script in power automate flow so it can also be ran in the web version of Excel, not just the desktop version.
I made a few adjustments to the VB code:
When a name is selected from the drop down in column L,
the time is automatically entered in to the the adjacent cell in column K and the time is adjusted depending on the name,
Then "In Progress" is automatically entered in to the adjacent cell in column J ,
and the old cell with "In Progress" will automatically change to "Complete."
Here is the VB code I am running:
Private Sub Worksheet_Change(ByVal Target As Range)
On Error Resume Next
Application.EnableEvents = False
Dim startTime As Double
startTime = Timer ' Record the start time in seconds
Dim rng As Range
Set rng = Intersect(Target, Me.Columns("L"))
If Not rng Is Nothing Then
Dim cell As Range
For Each cell In rng
Dim currentTime As Date
currentTime = Now
' Check elapsed time and exit loop if it's been running for more than 1 second
If Timer - startTime > 1 Then
Exit For
End If
Select Case cell.Value
Case "Romeo"
cell.Offset(0, -1).Value = currentTime + TimeValue("03:00:00") ' Offset to K column
cell.Offset(0, -2).Value = "In Progress" ' Offset to J column
Case "Shawn", "Justin"
cell.Offset(0, -1).Value = currentTime ' Offset to K column
cell.Offset(0, -2).Value = "In Progress" ' Offset to J column
Case "Davian", "Derek"
cell.Offset(0, -1).Value = currentTime + TimeValue("01:00:00") ' Offset to K column
cell.Offset(0, -2).Value = "In Progress" ' Offset to J column
Case "Jimmy", "Bobby", "Toni"
cell.Offset(0, -1).Value = currentTime + TimeValue("02:00:00") ' Offset to K column
cell.Offset(0, -2).Value = "In Progress" ' Offset to J column
Case Else
' Do not clear contents of J and K columns if the criteria are not met
End Select
' Update all other cells in column J with "In Progress" to "Complete" (within rows 1 to 100)
If cell.Offset(0, -2).Value = "In Progress" Then
Dim checkRange As Range
Set checkRange = Me.Range("J1:J100")
Dim inProgressAddresses() As String
Dim inProgressCount As Long
inProgressCount = 0
Dim checkCell As Range
For Each checkCell In checkRange
If checkCell.Address <> cell.Offset(0, -2).Address And checkCell.Value = "In Progress" Then
inProgressCount = inProgressCount + 1
ReDim Preserve inProgressAddresses(1 To inProgressCount)
inProgressAddresses(inProgressCount) = checkCell.Address
End If
Next checkCell
' Update all found "In Progress" cells to "Complete"
For i = 1 To inProgressCount
Me.Range(inProgressAddresses(i)).Value = "Complete"
Next i
End If
Next cell
End If
Application.EnableEvents = True
End Sub