+ Reply to Thread
Results 1 to 8 of 8

vba to create a number of rows, then copy/paste from source

  1. #1
    Registered User
    Join Date
    10-27-2010
    Location
    Mass
    MS-Off Ver
    Excel 2003
    Posts
    43

    vba to create a number of rows, then copy/paste from source

    I'm looking for some code to create 12 rows above (or below, whichever is easier) a selected row, then copy 12 rows from another sheet and paste them into the rows just created.

  2. #2
    Registered User
    Join Date
    10-27-2010
    Location
    Mass
    MS-Off Ver
    Excel 2003
    Posts
    43

    Re: vba to create a number of rows, then copy/paste from source

    Ok I've attached a sample of what my workbook looks like. On sheet 1 there are 6 similar sections, one for each of 6 different dogs. When I need to add a new dog, I want a macro that will create 12 rows above the selected row (in my real workbook there are a few hundred dogs in alphabetical order) and then copy/paste rows 5 through 16 from sheet 2 into those new rows.
    Attached Files Attached Files

  3. #3
    Registered User
    Join Date
    10-27-2010
    Location
    Mass
    MS-Off Ver
    Excel 2003
    Posts
    43

    Re: vba to create a number of rows, then copy/paste from source

    Any help on this? Seems like it would be pretty simple.

  4. #4
    Registered User
    Join Date
    02-05-2011
    Location
    Lodi, CA
    MS-Off Ver
    Excel 2007
    Posts
    22

    Re: vba to create a number of rows, then copy/paste from source

    Pretty basic recorded macro that might work, select line where you want to insert, then run macro.

    Please Login or Register  to view this content.
    I am sure someone else around here has a better idea but may work for now
    Last edited by sparky101747; 02-22-2011 at 02:03 PM. Reason: Took out offset

  5. #5
    Registered User
    Join Date
    10-27-2010
    Location
    Mass
    MS-Off Ver
    Excel 2003
    Posts
    43

    Re: vba to create a number of rows, then copy/paste from source

    I got that to work somewhat, but unfortunately it doesn't size everything correctly. When I do this process manually, I have to do it a certain way or the rows are the wrong size. Here is my process:

    1. Select a cell in the first row of a section (say... row 29 in my sample)
    2. Hit Alt + I + R, then F4 to repeat it 11 more times
    3. Go over to my section template on the other sheet
    4. Select rows 5 through 16 (it has to be the entire row or it doesn't paste correctly)
    5. Go back to the original sheet
    6. Select the first cell of the first newly created row
    7. Paste

    If i do it any other way, some of the rows are the wrong size.

  6. #6
    Registered User
    Join Date
    02-05-2011
    Location
    Lodi, CA
    MS-Off Ver
    Excel 2007
    Posts
    22

    Re: vba to create a number of rows, then copy/paste from source

    It worked fine for me, but I click on the number 29 to select that row not the cell. Try that and see if it works. Here's your sample with the macro (macro2) that I used.
    Attached Files Attached Files
    Last edited by sparky101747; 02-23-2011 at 11:34 AM.

  7. #7
    Registered User
    Join Date
    10-27-2010
    Location
    Mass
    MS-Off Ver
    Excel 2003
    Posts
    43

    Re: vba to create a number of rows, then copy/paste from source

    Hmm, ok now I'm getting it to work just fine after doing what you said. But a new problem I'm having is conditional formatting not working for the boarding in and boarding out columns in a freshly pasted section. The conditional formats are there and they look correct, but nothing happens when I enter today's date. If I make a new conditional format with the same conditions it works fine. Dunno what's going on.

  8. #8
    Registered User
    Join Date
    10-27-2010
    Location
    Mass
    MS-Off Ver
    Excel 2003
    Posts
    43

    Re: vba to create a number of rows, then copy/paste from source

    Bump, still have this problem

+ 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