+ Reply to Thread
Results 1 to 4 of 4

VBA to Copy and Paste Several Groups of Cells

  1. #1
    Registered User
    Join Date
    11-06-2010
    Location
    Vegas
    MS-Off Ver
    Excel 2017
    Posts
    51

    VBA to Copy and Paste Several Groups of Cells

    Thank you for looking at my problem. I am a begginner. Attached is a scaled down Input page for a large charity golf tournament benefiting wounded veterans. Several other sheets are tied to this Input sheet in a Workbook.

    Typically we will sign up 144 players which are equal to 36 foursomes. Once the tournament is sold out, we add several veterans to several foursomes as fifth members. It is usually 8 to 10 veterans, but in this illustration I have used 3. There is a box at the top of the page under the word "Control." This controls how many foursomes and fivesomes are listed. In this case I have changed 144 players to 147 players, which is equal to 33 foursomes and 3 fivesomes. The fivesomes are created at the bottom of the list starting with the 36th group and working upward.

    I am trying to write a macro that will easily allow the fifth group members to be added. I have added an additional sheet called "Desired Result" to show what I am trying to do. Basically the macro would copy cells D140:F147 (Row 147 is the last row with data) and paste to D141, then clear the contents in D140:F140; then copy cells D145:F148 (Row 148 is now the last row with data) and paste to D146, then clear the contents in D145:F145. The names of the three "fifth players" can then be filled in.

    I am still a beginner, but I have tried to put together a macro to accomplish this. The macro "AddFifthPlayers" does successfully select and copy the first group of cells using the Group # in Column I, but it will not paste them in the first cell below which is D141. I get the message "Run-time error ‘1004’: You can’t paste this here because the Copy area and paste area aren’t the same size. Select just one cell in the paste area or an area that’s the same size, and try pasting again." This does not make sense to me since only one cell (D141) in the paste area is selected. I am probably missing something obvious.

    This forum is a huge learning assistant for struggling beginners like me. I have tried for hours to make this work, but cannot figure it out. Thank you again.
    Attached Files Attached Files

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: VBA to Copy and Paste Several Groups of Cells

    Please Login or Register  to view this content.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Registered User
    Join Date
    11-06-2010
    Location
    Vegas
    MS-Off Ver
    Excel 2017
    Posts
    51

    Re: VBA to Copy and Paste Several Groups of Cells

    Brilliant! Thanks, AlphaFrog. Works perfectly.

  4. #4
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: VBA to Copy and Paste Several Groups of Cells

    You're welcome redrocker12. It's a pleasure answering a query that is explained in detail with an example workbook that includes a Desired Results sheet. Most of the time, understanding the question is harder than answering it. Not in this case. Well done.

+ 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] Copy/Paste Conditional Formatting of Groups of Cells in Multiple Directions
    By Hellogiraffe in forum Excel General
    Replies: 5
    Last Post: 04-24-2019, 02:43 PM
  2. [SOLVED] (VBA) How Assign Column Cell To Corresponding Group, and Paste Group Cells into Groups WS?
    By eryksd in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 02-08-2016, 06:18 PM
  3. Replies: 1
    Last Post: 01-16-2013, 05:36 AM
  4. [SOLVED] Copy Groups of cells, Add headers
    By Jimbo42 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-05-2012, 01:26 PM
  5. Replies: 6
    Last Post: 12-09-2011, 05:22 AM
  6. Copy and Paste Groups of Same Values
    By angoodkind in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-23-2010, 09:28 PM
  7. Copy and paste without groups
    By watsthatabout in forum Excel General
    Replies: 3
    Last Post: 04-20-2009, 09:43 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