Hello to all,
I'll start by saying that I am pretty new to VBA and might be quite spotty with my knowledge. So, if I seem to be at a fault because I don't know the basics I apologize. Just excuse any obvious things I've missed. I don't mind having things explained in a degrading manner.
Anyways...
I'm writing macros to process my data into printable invoices. I've been doing pretty well with stage 1 (preparing the list of data) but am stuck at the end. In this case the important data fields are my "Card #" and my "Product #". I have all my data sorted ascending, 1st by "Card #" and 2nd by "Product #". A common set of entries looks like this...
Card # -- Prod #
848001 - 1
848001 - 1
848001 - 1
848001 - 1
848001 - 2
848001 - 2
848002 - 1
848002 - 1
848003 - 1
I need to have a loop go through all the entries and add a row at the end of EVERY Product # per Card #. So in the above case I would need it to look like this in the end...
Card # -- Prod #
848001 - 1
848001 - 1
848001 - 1
848001 - 1
848001 - 2
848001 - 2
848002 - 1
848002 - 1
848003 - 1
...of course I would do additional formatting to the added rows but I think if I could get this far I could manage the rest on my lonesome.
I've tried a few things. For example I've tried using a 'For Each Next' loop with nested 'If Then Else' statements in it. I had the 'If Then Else' statements running against the values of the previous cells. If they differed in either column I added a row. Unfortunately I couldn't succeed in my attempt.
Any suggestions or examples would be GREATLY appreciated. I've been trying all night and would love for a little help.
Bookmarks