+ Reply to Thread
Results 1 to 5 of 5

VBA to enter x number of blank rows by group

  1. #1
    Valued Forum Contributor
    Join Date
    11-20-2003
    MS-Off Ver
    2010, 2016
    Posts
    1,176

    VBA to enter x number of blank rows by group

    I have a rows of data and I want to group similar data into groups of 6 rows for each. For example my data in column A is a follows:


    123
    123
    123
    39000
    39000
    54
    6000000
    5000
    5000
    5000
    5000

    My desired output is as follows:
    123
    123
    123
    [blank row]
    [blank row]
    [blank row]
    39000
    39000
    [blank row]
    [blank row]
    [blank row]
    [blank row]
    54
    [blank row]
    [blank row]
    [blank row]
    [blank row]
    [blank row]
    6000000
    [blank row]
    [blank row]
    [blank row]
    [blank row]
    [blank row]
    5000
    5000
    5000
    5000
    [blank row]
    [blank row]

    As you can see, if a group has 3 line items, insert 3 blank rows below. If a group has 4 line items, insert 2 blank rows below and so on.

  2. #2
    Forum Contributor
    Join Date
    08-16-2012
    Location
    Sydney
    MS-Off Ver
    Excel 2019
    Posts
    209

    Re: VBA to enter x number of blank rows by group

    Hi Maac,

    I do not get the logic of inserting the blank row
    If a group has 3 lines, insert 3 lines
    If a group has 4 lines, insert 2 lines
    so what happened if a group has 1 line? do u insert 4 lines (your picture showing 5)
    and if a group has 6 lines, how many blank line you required?

    Cheers
    Lex

  3. #3
    Valued Forum Contributor
    Join Date
    11-20-2003
    MS-Off Ver
    2010, 2016
    Posts
    1,176

    Re: VBA to enter x number of blank rows by group

    my mistake....if 1 line, insert 5 lines. If 6 lines, insert no lines. Thanks

  4. #4
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: VBA to enter x number of blank rows by group

    I think this will do what you want.
    Please Login or Register  to view this content.
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  5. #5
    Valued Forum Contributor
    Join Date
    03-21-2013
    Location
    cyberia
    MS-Off Ver
    Excel 2007
    Posts
    457

    Re: VBA to enter x number of blank rows by group

    alternative
    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)

Similar Threads

  1. [SOLVED] Code to enter blank rows
    By jscalem in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-08-2014, 03:13 PM
  2. Missing number enter in blank column / row with no duplicate value
    By avk in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 06-29-2013, 06:53 AM
  3. [SOLVED] Need VBA code to count number of rows & split into group of 7 rows in same sheet
    By amy_d2 in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 06-05-2013, 11:03 AM
  4. Insert rows and enter data in blank cells.
    By jscalem in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-22-2013, 06:47 AM
  5. Replies: 1
    Last Post: 07-18-2012, 04:49 AM

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