• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User


  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Insert blank rows above a table based on unique values in one of the columns in the table


First, my apologies if anything I write is unclear or if I have not provided sufficient information. I almost never have the opportunity to work with vba, so when I do get to play around with it once or twice every year or two, I come at it as an absolute newb.

My question (with some details):

I copied some vba from a previous macro that splits data from a table in one sheet onto several new sheets based on contents in cells of one of the columns in the original sheet. In other words, if there are three unique strings in column E, then my macro creates three new sheets with names that match the unique strings in column E in the original table, and then it copies rows of data from the original table that contain each unique string, and pastes those rows into the corresponding new sheet. This code is working perfectly (even thought I don't understand how it all works).

What I want to happen next is, on each of the newly created sheets, I want to count the number of unique strings in column B, then insert that number of blank rows + 5 at the top of the sheet. In other words, if there are 5 unique strings in column B, then I want to insert 10 blank rows at the top of the sheet. I don't know if it matters, but the new sheets will always start at the 4th sheet (first three sheets are fixed, and will always be present). Possible names of the new sheets are, "ICO RWE", "ICO RWE-RSH", "ICO RSH", "ICR SSU", and "ICR MED", but not all sheets will always be present. For example, one workbook might only have "ICO RWE" and "ICO RSH".

Any and all help is greatly appreciated. Please let me know if more details are needed.

Thank you!