I have a table in which I would like to apply Days, Hours and Wages in columns for a number of staff members. To keep all the staff reecords visible I was hoping that I could use the same headings multiple times instead of using unique column headers, then add the name of the staff member to merged cells in the row above each set of three columns.
I only want to maintain weekly records for the most recent 52 weeks so as each new record is added I want the earliest record to be deleted. I have the code to run this in the worksheet.
One solution to the naming protocol would be to use separate tables for each employee, however the code does not work with multiple tables.
I am hoping that there are possible solutions which will either
a) allow duplicated column headers in the same table or
b) an altered code to allow the earliest record to be removed as soon as a new record is added to any table in the worksheet.
Many thanks
I only want to maintain weekly records for the most recent 52 weeks so as each new record is added I want the earliest record to be deleted. I have the code to run this in the worksheet.
One solution to the naming protocol would be to use separate tables for each employee, however the code does not work with multiple tables.
I am hoping that there are possible solutions which will either
a) allow duplicated column headers in the same table or
b) an altered code to allow the earliest record to be removed as soon as a new record is added to any table in the worksheet.
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
With ActiveSheet.ListObjects(1)
If Not Intersect(Target, .DataBodyRange) Is Nothing Then
Application.ScreenUpdating = False
Application.EnableEvents = False
Do Until .DataBodyRange.Rows.Count <= 54
.ListRows(1).Delete
Loop
Application.EnableEvents = True
Application.ScreenUpdating = True
End If
End With
End Sub
Many thanks