Are the account details in the rows or columns? Are the departments in the rows or columns?

If you have a picture of what you are trying to create, or a spreadsheet that you are doing manually, then posting that would be helpful.
_________________________
Andrew Bates