MattHaynes
New Member
- Joined
- Sep 22, 2022
- Messages
- 1
- Office Version
- 365
- Platform
- Windows
I have a table that has a dropdown in cell E6 for "Stage 1" "Stage 2" and "Stage 3" on each selection in cell G6 there is a timestamp that changes every time another option is selected.
I then have a audit trail sheet with the following VBA code.
I am trying to have a separate sheet with a time table to show timestamps of when stage have been changed. For example when stages "Mainsheet!E6" was changed from "Stage 1" to "Stage 2" a timestamp is placed in "Timestamps!B4" then when "Mainsheet!E6" is changed from "Stage 2" to "Stage 3" a new timestamp is placed in "Timestamps!C4".
My thought was to have a formula in Timestamps!B4 that is
This formula works as it shows the timestamp when Stage 1 is showing but when changed to Stage 2 it disappears.
If you have any help that would be helpful thank you.
If you have any help please let me know.
I then have a audit trail sheet with the following VBA code.
VBA Code:
Option Explicit
Dim wsLOE As Worksheet, wsTrail As Worksheet
Dim PreviousValue As Variant
Private Sub Worksheet_Change(ByVal Target As Range)
Set wsTrail = ThisWorkbook.Worksheets("Trail")
If Cells(5, Target.Column).Value = "Stage" Or Cells(5, Target.Column).Value = "Allocated" Then
If Target.Value <> PreviousValue Then
Call Log_Change(Target)
End If
End If
End Sub
Private Sub Log_Change(ByVal Cell_Target As Range)
Dim RowInsertion As Long
RowInsertion = wsTrail.Cells(Rows.Count, "A").End(xlUp).Row + 1
wsTrail.Cells(RowInsertion, "A").Value = _
Application.UserName & " changed cell " & Cell_Target.Address & " on " & ActiveSheet.Name & " from " & PreviousValue & " to " & Cell_Target.Value _
& " on the timeline" & " timestamped at " & Format(Now(), "dd-mm-yy hh:mm:ss")
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
PreviousValue = Target.Value
End Sub
Private Sub Worksheet_Deactivate()
Set wsLOE = Nothing
Set wsTrail = Nothing
End Sub
I am trying to have a separate sheet with a time table to show timestamps of when stage have been changed. For example when stages "Mainsheet!E6" was changed from "Stage 1" to "Stage 2" a timestamp is placed in "Timestamps!B4" then when "Mainsheet!E6" is changed from "Stage 2" to "Stage 3" a new timestamp is placed in "Timestamps!C4".
My thought was to have a formula in Timestamps!B4 that is
Excel Formula:
=IF('QB1'!H6="Stage 1",'QB1'!J6,"")
This formula works as it shows the timestamp when Stage 1 is showing but when changed to Stage 2 it disappears.
If you have any help that would be helpful thank you.
If you have any help please let me know.