Copying and Pasting Non-Contiguous Ranges of Cells

Written by Allen Wyatt (last updated January 31, 2026)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, 2021, 2024, and Excel in Microsoft 365


1

Szilvia can create a selection set of cells, such that she has a non-contiguous range of cells selected. If she tries to copy those cells using Ctrl+C, Excel informs her that "this action will not work on multiple selections." Szilvia wonders if there a way to copy a non-contiguous range and then paste that range so that the cells are in the same relative position as in the original selection.

Apparently, this limitation of only allowing you to copy and paste contiguous ranges is the way that Excel is designed to work. The only way you can copy and paste a non-contiguous range is to use a macro—one that steps through each area in a selection and pastes it relative to a target address.

There is one exception to this limitation, however. If your non-contiguous selection consists of ranges that all come from the same rows, you can copy and paste them using the standard Ctrl+C and Ctrl+V commands. For example, if you select the range A13:D16, then hold Ctrl and select F13:G16, you can copy and paste these ranges. The pasted data will appear in adjacent columns in the destination. This works because the rows are aligned across all selected areas.

For all other cases where the non-contiguous ranges are not row-aligned, you will need to use a macro. The following macro provides a robust solution:

Sub CopyPasteCells()
    Dim Area As Range
    Dim PasteRng As Range
    Dim C As Integer
    Dim R As Double
    Dim X As Integer
    Dim Y As Double

    On Error Resume Next
    Set PasteRng = Application.InputBox("Target cell?", Type:=8)
    If PasteRng Is Nothing Then Exit Sub
    On Error GoTo 0

    C = Selection.Column
    R = Selection.Row
    For Each Area In Selection.Areas
        X = Area.Column
        If X < C Then C = X
        Y = Area.Row
        If Y < R Then R = Y
    Next Area
    
    C = PasteRng.Column - C
    R = PasteRng.Row - R
    For Each Area In Selection.Areas
        Area.Copy Cells(Area.Row + R, Area.Column + C)
    Next Area
    Application.CutCopyMode = False
End Sub

This macro works by using VBA's Areas collection to copy each contiguous block of the selection at a time, which is faster than copying cell by cell. It correctly calculates the relative position of each area and pastes it in the proper location relative to the target cell you specify.

To use the macro, create your selection set of cells (holding Ctrl while clicking to select non-contiguous ranges). Then, run the macro and specify the target cell for the pasting. Excel displays an input box where you can either type the cell address or click directly on the target cell. The cells are pasted relative to that target cell on the current worksheet, maintaining their original spacing and positions.

If you need to cut and paste (rather than copy and paste), you can modify the macro by changing Area.Copy to Area.Cut in the second For Each loop.

Note:

If you would like to know how to use the macros described on this page (or on any other page on the ExcelTips sites), I've prepared a special page that includes helpful information. Click here to open that special page in a new browser tab.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (5228) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, 2021, 2024, and Excel in Microsoft 365.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Special Differences when Searching

Word includes two different search engines. Which search engine you choose to use will dictate what Word shows as ...

Discover More

Counting the Number of Blank Cells

If you need to count the number of blank cells in a range, the function to use is COUNTBLANK. This tip discusses the ...

Discover More

Indexing a Range of Pages

After you get your document ready for indexing by inserting index fields throughout it, you may want to index only a ...

Discover More

Create Custom Apps with VBA! Discover how to extend the capabilities of Office 365 applications with VBA programming. Written in clear terms and understandable language, the book includes systematic tutorials and contains both intermediate and advanced content for experienced VB developers. Designed to be comprehensive, the book addresses not just one Office application, but the entire Office suite. Check out Mastering VBA for Microsoft Office 365 today!

More ExcelTips (ribbon)

Merging Cells to a Single Sum

One way to make your worksheets less complex is to get rid of detail and keep only the summary of that detail. Here's how ...

Discover More

Pasting without Updating References

Do you need to paste formulas without updating the references in whatever you are pasting? You can accomplish this, ...

Discover More

Getting Rid of Everything Except Numbers

Got some numbers and letters mixed up in the same cell? You may need to get rid of those letters so you are left with ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] (all 7 characters, in the sequence shown) in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is 7 + 5?

2026-01-31 12:05:41

Tomek

Re: There is one exception to this limitation, however. If your non-contiguous selection consists of ranges that all come from the same rows, you can copy and paste them using the standard Ctrl+C and Ctrl+V commands
The exception is a little wider: if your non-contiguous selection cells form a rectangular matrix, such that the selected cells would for a fully populated rectangle when all non-selected cells were hidden, then such block of cells can be copied and pasted as a single rectangular block. There is one additional requirement that is best illustrated by example: if you select a block of three cells in one row, then all selections from rows below have to be three cells wide in the same columns, i.e., you cannot select three-cells block one row and three individual cells below. All selected areas have to match the height of other areas to the right and the width of the areas below.
This copy and paste functionality is important when you want to extract data after filtering them, or after hiding some rows and/or columns.
The limitation is that the non-selected rows and columns are ignored and the selected cells are collapsed into a single area.


This Site

Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.

Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.