+ Reply to Thread
Results 1 to 4 of 4

make number of rows between 2 cells values uniform throughout a worksheet

  1. #1
    Forum Contributor
    Join Date
    11-04-2012
    Location
    Australia
    MS-Off Ver
    Excel 2016
    Posts
    334

    make number of rows between 2 cells values uniform throughout a worksheet

    I am looking to write a macro that will find 2 cell values and then make the number of rows in between those 2 cell values uniform throughout a worksheet.

    Example:
    I have attached a sample worksheet
    All the data is in column A
    I need to find a cell value 'Group1' , then find a second cell value 'Group2' and then count the rows in between the two. If the result is 15, then all is good. If there are less than 15 rows between the 2 I need to add however many rows to make it 15.

    I need the macro to loop through the worksheet to check that there are 15 rows between Group2 and Group3 and 15 rows between Group3 and Group4 etc.



    I am guessing that the same thing could be achieved using 'do until' however I do not know how that will work..... with my limited VBA knowledge.

    I need each 'group' to be a specific size because I will be adding in columns after I make each 'group' the same size.

    I realise that it is relatively straight forward to merge 2 workbooks, however, I cannot merge my 2 workbooks...as you can see from the example worksheet, the data in the rows that follow each 'Group' is the same for each group, but there is nothing to match with the data that I need to append.

    The number of Groups is variable (from 1 to 150), but they always run sequentially down Column A.

    Any help appreciated.

  2. #2
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: make number of rows between 2 cells values uniform throughout a worksheet

    Hi annrichards22

    This code appears to do as you require. Let me know of issues.
    Please Login or Register  to view this content.
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

  3. #3
    Forum Contributor
    Join Date
    11-04-2012
    Location
    Australia
    MS-Off Ver
    Excel 2016
    Posts
    334

    Re: make number of rows between 2 cells values uniform throughout a worksheet

    Thank you so much John your code works perfectly.

    If I need to make the values XX rows apart can I simply change 16 to XX?

  4. #4
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: make number of rows between 2 cells values uniform throughout a worksheet

    Hi annrichards22

    That's correct. Or you could use a User Input Box and ask the User to indicate the value of XX. Then replace the two incidents of 16 with XX such as this
    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1