Hi all ,
I have an excel Table dynamically Sorting this part works but the dynamically add datetime on record entry does not seem to work. If I add 2 rows of same itemcode e.g.: 5001 and delete top row of the 2 newly enterd records
then date appears on t remaining record.
I am no expert in the excel vba syntax how to put these 2 functions into 1 statement
any help appreciated
thank you Peter
I have an excel Table dynamically Sorting this part works but the dynamically add datetime on record entry does not seem to work. If I add 2 rows of same itemcode e.g.: 5001 and delete top row of the 2 newly enterd records
then date appears on t remaining record.
I am no expert in the excel vba syntax how to put these 2 functions into 1 statement
VBA Code:
Sub Worksheet_Change(ByVal Target As Range)
Dim SalesTable As ListObject
Dim SortCol As Range
Set SalesTable = ActiveSheet.ListObjects("Sales2022")
Set SortCol = Range("Sales2022[Code]")
'auto sort on enter
If Not Intersect(Target, SortCol) Is Nothing Then
With SalesTable.Sort
.SortFields.Clear
.SortFields.Add Key:=SortCol, Order:=xlAscending
.Header = xlYes
.Apply
'Now auto add datetime in column5 on enter
'If Not Intersect(Target, SortCol) Is Nothing Then
'insert date on data entered
With Target(1, 5) ' column E add datetime on the fly
.Value = Now
.EntireColumn.AutoFit
End With
' End If
End With
End If
End Sub
any help appreciated
thank you Peter