I am trying to write a macro where I separate groups into different sheets. Basically, I have a list of people in different 4-digit departments that have to each go into their department number's sheet. However, sheets have to be created for each dept number as they don't exist already. Also, these dept number sheets have to be based off of a form sheet that already exists (so copied and renamed for each dept #).
for example:
3344 joe smith
3344 steve smith
4455 john jones
4455 john smith
I don't know how to make it go as follows (for example):
if dept number is greater than the one before (ie. is 4455 greater than 3344? yes, so create a new "4455" sheet and move that person's info over to it. Then, is 4455 greater than 4455? no, so just move that person's info into the "4455" sheet that is already there). and so on...
Can this be done? how do I make it look at the person's dept number in the previous row to compare to? can it be "stored" somewhere and move in and out for each person in the list?
also, I can't hardcode dept numbers in as they will constantly changing...
I have read through 3 vba books and can't find anything that will help me do what I'm trying to do, so any help is greatly appreciated!!
Thanks so much again for any help.