I have an excel source with the following headings
Staff Number
Name
Allowance
Amount
Each employee appears one or more times, as they can have more than one allowance. The list is sorted by staff number, so the records are together for each staff member.
I need to create a document per person which includes Staff Number & Name once, followed by a list of allowances and amounts e.g.
Staff Number: - 123456
Name: - Fred
Allowances Amounts
Basic Pay 25750
Management 1650
Shift 21750
Skip helpfully told me the following
So here is the code in question...
Thanks for the help
Jonathan
Staff Number
Name
Allowance
Amount
Each employee appears one or more times, as they can have more than one allowance. The list is sorted by staff number, so the records are together for each staff member.
I need to create a document per person which includes Staff Number & Name once, followed by a list of allowances and amounts e.g.
Staff Number: - 123456
Name: - Fred
Allowances Amounts
Basic Pay 25750
Management 1650
Shift 21750
Skip helpfully told me the following
I'd do it all in Excel. You'll have to record and modify a simple macro.
You will need a unique list of your employees from your source data. This can be done using the Advanced filter - UNIQUE values, no criteria. Copy this unique list to a new, separate sheet.
Use the AutoFilter in your source data, to select an employee. Turn on your macro recorder and record selecting the employee.
Post back with your recorded code in forum707: VBA Visual Basic for Applications (Microsoft) for help cusomizing.
So here is the code in question...
Code:
Sub Macro1()
Sheets("Sheet1").Select
Range("A1").Select
Selection.AutoFilter
Selection.AutoFilter Field:=2, Criteria1:="John"
End Sub
Thanks for the help
Jonathan