+ Reply to Thread
Results 1 to 2 of 2

Macro to Copy/Insert Copied cells based on user input # of rows/formatting rules

  1. #1
    Forum Contributor
    Join Date
    06-16-2014
    Location
    United States
    MS-Off Ver
    Home 2010
    Posts
    122

    Macro to Copy/Insert Copied cells based on user input # of rows/formatting rules

    I have a spreadsheet like so:

    lines.png

    I have 20 blocks like the one above, and I would like to create a macro which does the following:

    1. Ask user how many rows to add. Entry must be less than or equal to the Current No. of rows minus 3 as per the grey filled cell in column C of that block. This can be done by reading the value in the first grey-filled cell of column C moving downward from the current mouse location.
    2. Copy # of rows from step 1
    3. "Insert copied cells" two rows from the grey line of that block.

    Using the above image as an example:

    I have 28 rows total.
    I run the macro, and a message box asks me how many rows to add, with a note saying that I cannot add more than 25 rows (28-3).
    I enter 28. I get an error message saying I cannot add more than 25 rows, and it asks me to enter again.
    I enter 24.
    Rows are selected and copied from Row 3 (one row below the top row of the block) to Row 26 (Row 3 plus # of rows entered)
    Copied rows are inserted as "Insert Copied Cells" command (To maintain formulas/formatting etc.) below the last copied row. So, in this case, these rows will be copied starting at Row 27.


    If this was done manually:

    Selecting entered cells (24)

    select.png

    Copying selected cells:

    copy.png

    Insert Copied cells:

    insert.png

  2. #2
    Forum Contributor
    Join Date
    06-16-2014
    Location
    United States
    MS-Off Ver
    Home 2010
    Posts
    122

    Re: Macro to Copy/Insert Copied cells based on user input # of rows/formatting rules

    Continued from Post # 1:

    Result (Notice the change in Current No. of rows):

    result.png

+ 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 and insert rows based on user input
    By Groovicles in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 03-27-2015, 10:34 AM
  2. Insert X number of Copied row based on user input
    By KT99 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 10-27-2014, 11:19 AM
  3. Insert # of Rows based on User Input
    By afpilotb1 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-23-2014, 11:40 AM
  4. Macro to Copy Rows based on User Input
    By CharterJP in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 07-24-2012, 06:13 PM
  5. [SOLVED] Macro based on User input to Insert X amount of rows - Need advanced help
    By BuzzOffSweetheart in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-19-2012, 07:06 PM
  6. Insert rows based on user input from cell value in other sheet
    By MrPisky in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 10-31-2011, 09:08 PM
  7. macro to copy cells based on user input
    By pankaj2145 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-03-2009, 04:54 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