+ Reply to Thread
Results 1 to 3 of 3

Macro for inserting rows on a dataset

  1. #1
    Registered User
    Join Date
    03-28-2010
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2007
    Posts
    38

    Macro for inserting rows on a dataset

    Hi,

    I'm new to VBA and need help in creating a macro for inserting rows on 2 conditions.

    1st Condition - insert 3 rows between different "Divisions"
    2nd Condition - insert 2 rows between the same "Division" but different "Sub Divisions"

    Col A - Col B
    Division - Sub Division
    1 - 4
    1 - 4
    1 - 3
    1 - 2
    2 - 5
    2 - 5
    2 - 6
    2 - 7
    3 - 8
    3 - 8
    3 - 9
    3 - 0

    Hope someone can help me out. Any help would be truly appreciated

    Thanks,
    Sunil Wadhwa

  2. #2
    Forum Contributor
    Join Date
    03-11-2010
    Location
    India
    MS-Off Ver
    2010
    Posts
    268

    Re: Macro for inserting rows on a dataset

    loop for each row, store col A and B values for each row in two variables. compare values with values in last iteration. in case of change, insert rows as reqd.

    hth
    ajay

  3. #3
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Macro for inserting rows on a dataset

    Please Login or Register  to view this content.

    Try this out:
    Please Login or Register  to view this content.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

+ 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