+ Reply to Thread
Results 1 to 4 of 4

Create a Looping macro which copies and inserts rows

  1. #1
    Registered User
    Join Date
    11-18-2007
    Posts
    2

    Create a Looping macro which copies and inserts rows

    Hi,
    I am new to VBA based macros and I have the following problem which I am struggling to sort out, if anybody can help me or give any pointers to get started I would be greatfull.

    I regularly download a file into Excel which is a long list detailing part numbers and quanities. I want to write a macro which will copy each row in turn, inserting a new row and pasting the data according to the quanitity specified. It must stop when there are no new lines to copy.
    A basic illustration of the problem is below;

    Part No Description Qty

    G123XY Tap 3
    DAS65W Sink 4

    Hence the macro should copy the row which starts G123XY and create 3 new lines above or below with the same data, and then move on to the row which starts with DAS65W and do the same thing 4 times.
    The end result reading;
    Part No Description Qty

    G123XY Tap 3
    G123XY Tap 3
    G123XY Tap 3
    DAS65W Sink 4
    DAS65W Sink 4
    DAS65W Sink 4
    DAS65W Sink 4

    The reason I want to be able to do this is so that I can use Word or similar to mailmerge some labels for the products but I want 1 label for each item and one per line.

    Hope somebody can help out or at least give me a few pointers.

    Thanks

    Ben

  2. #2
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967
    This short macro should do the trick

    Please Login or Register  to view this content.
    Martin

  3. #3
    Registered User
    Join Date
    11-18-2007
    Posts
    2

    Create a Looping macro which copies and inserts rows

    Thanks,
    I get cracking trying to build on this.
    Cheers

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643
    Try 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