+ Reply to Thread
Results 1 to 6 of 6

VBA to Cut and insert Multiple Non-Contiguous Ranges

  1. #1
    Forum Contributor
    Join Date
    12-14-2012
    Location
    Davenport, Iowa
    MS-Off Ver
    Excel 365
    Posts
    206

    VBA to Cut and insert Multiple Non-Contiguous Ranges

    Hi,

    I was wondering if it would be possible to create macro where I can select multiple ranges (All within the same columns and rows) and then select an area I wan the data to be cut to. Problem is I get an error message when I attempt to cut and insert the data.

    I did find the following code which works well with the exception that I need it to cut and insert at the destination cell.

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by sriley5; 07-09-2019 at 04:18 PM. Reason: Clarification

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

    Re: VBA to Cut and insert Multiple Non-Contiguous Ranges

    The destination area cannot overlap the copied cells area. Your first area is four rows and you are trying to paste it two rows above which means part of the destination area overlaps the source. That causes the error. Consider inserting rows where you want to paste. Or paste to a dummy area on the sheet and copy the dummy area to the actual destination.
    Last edited by AlphaFrog; 07-10-2019 at 12:49 AM.
    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
    Forum Contributor
    Join Date
    12-14-2012
    Location
    Davenport, Iowa
    MS-Off Ver
    Excel 365
    Posts
    206

    Re: VBA to Cut and insert Multiple Non-Contiguous Ranges

    Thanks, I understand the error, but trying to figure out how I can take my existing code from above and perform that function if it is possible, so rather than copying it, I want it to cut and insert to the destination cell. Any thoughts on how I could make that adjustment?

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

    Re: VBA to Cut and insert Multiple Non-Contiguous Ranges

    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    12-14-2012
    Location
    Davenport, Iowa
    MS-Off Ver
    Excel 365
    Posts
    206

    Re: VBA to Cut and insert Multiple Non-Contiguous Ranges

    Getting closer, I attached an updated workbook, but it appears that not everything makes it to the target range - the data is being split for some reason... Attached is the workbook with a sheet called After Actual - showing what I get after running the script on the "Before Sheet". This is after I have selected all the green cells holding the control key...

    Please Login or Register  to view this content.

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

    Re: VBA to Cut and insert Multiple Non-Contiguous Ranges

    Because it now inserts the rows instead of pasting, ThisRng (B15) automatically shifts down for each area inserted. There is no need to offset from ThisRng. It's always at the bottom of the last inserted area.

    Try this. (removed the Offset(i))

    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)

Similar Threads

  1. Replies: 0
    Last Post: 06-14-2019, 03:28 PM
  2. Replies: 10
    Last Post: 08-12-2017, 09:57 AM
  3. [SOLVED] Data Validation - Multiple selections in multiple columns
    By 1953CAG in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-10-2016, 11:23 AM
  4. omit menu items via data validation for multiple selections and multiple menus when select
    By themattyp503 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-03-2014, 12:16 AM
  5. List Box Selections Outputting Multiple Selections with One Click
    By Mordred in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 07-21-2011, 12:27 PM
  6. Multiple selections from a pick list - only unique selections (no repeats) ?
    By opsayo in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-24-2011, 06:25 PM
  7. Replies: 0
    Last Post: 11-19-2005, 11:15 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