When the user selects a cell within an already populated portion of a list, the original contents are copied into column B of the same row. I then need a pause or something, so if the user types something different in the cell I can capture the new contents and compare to the old, if different then the date/time stamp (will be put in column F) will be updated otherwise left untouched.
Have marked where I think the pause should go in the code below with " 'User changes cell "
Can anyone help please?
Have marked where I think the pause should go in the code below with " 'User changes cell "
Can anyone help please?
VBA Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim ListsRnge As Range
Dim OldColCCnt As Integer
Dim OldColECnt As Integer
Dim OldColGCnt As Integer
Dim ChngCol As Integer
Dim ChngRow As Integer
'Dim OldContent As String
Dim NewContent As String
'Specify ListsRnge: columns C&D = Chill, columns E&F = Focus, columns G&H = Sleep
Set ListsRnge = Range("C9:H500")
'Check if changed cell is in one of the above required columns, if not don't run routine
If Intersect(Target, ListsRnge) Is Nothing Then Exit Sub
'Switch off events
Application.EnableEvents = False
'Count number of rows already populated in each of the columns C, E and G
OldColCCnt = Cells(Rows.Count, "C").End(xlUp).Row
OldColECnt = Cells(Rows.Count, "E").End(xlUp).Row
OldColGCnt = Cells(Rows.Count, "G").End(xlUp).Row
'Determine which of the Updated date/times should change
ChngCol = Target.Column
ChngRow = Target.Row
If ChngCol = 3 And Target.Row <= OldColCCnt Then
'Put old cell content into column B, same row
Cells(ChngRow, 2).Value = Target.Value
'User changes cell
NewContent = Target.Value
End If