+ Reply to Thread
Results 1 to 2 of 2

Macro for copying and inserting a row

  1. #1
    Registered User
    Join Date
    01-19-2010
    Location
    West Yorkshire
    MS-Off Ver
    2007
    Posts
    1

    Macro for copying and inserting a row

    I have a spreadsheet, an example of which can be viewed in the picture 'excel1.jpg' attached to this post, that i need to format correctly to upload to a webserver to update products. The first row is the database field names with each product below that. This would be fine for most shopping cart software, but mine only imports the first product. After running a few tests i discovered that if i include the database fields (row1) above each individual product it will import fine. So what i need is a macro that will copy and insert the first row above each product, basically so it looks like the picture 'excel2.jpg' attached. The data in the pictures is test data as my spreadsheet has approx 1,500 records. Is there a way to do this? Many thanks.
    Attached Images Attached Images

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Macro for copying and inserting a row

    Hi,
    Probably the easiest way to do this is as follows.

    In a spare column say K, in row 2 enter the value 2, and in row K3 the formula = K2+2.

    Now copy this down all 1500 rows and copy and paste special values all these numbers.

    Now in a second spare column do the same but in say L2 enter 1, and in L3 =L2+2 and copy these down. Now copy the whole of L2:L1500 and paste special values underneath the last used cell in column K.

    Now sort the whole of your data using column K as the primary key to end up with your data distributed on every other row.

    Now filter the data for blanks on any column other than K or L and then copy row 1 down all the blank rows.

    Finally unfilter your data.

    HTH
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

+ 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