Please find the attached sample data file for your reference. this data file have two tabs, input and output.
input tab contains the data and output tab have the output for the input data.
are confusing in relation to your question. If I were to guess I would say Output Data is the tab that is meant to be the Input tab. If this is the case then a pivot table and not VBA is the way to go IMO.