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


2

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

Displaying the Document Title Right Away

One of the properties that Word maintains for a document is a title. If you want this title displayed on the title bar ...

Discover More

Forcing a Page Break Before a Paragraph

There are times that you just want to begin a paragraph (perhaps a heading) at the top of a new page. Word allows you to ...

Discover More

Jumping to Alphabetic Worksheets

Got a workbook with a lot of worksheets in it? Here are some handy ways to jump to the worksheet you want, alphabetically.

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)

Enhanced Filling

Using the AutoFill feature of Excel is very handy. If you want to expand the utility offered by the feature, all you need ...

Discover More

Proper Case Conversion with Exceptions

The PROPER worksheet function allows you to change the case of text so that only the first letter of each word is ...

Discover More

Identifying Duplicates

Do you need to flag duplicate values in your data? This tip shows three different ways you can do the flagging you need.

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 one less than 1?

2026-02-02 10:08:11

J. Woolley

The Tip's macro is very clever, but it fails when PasteRng (i.e., "Target cell") is not on the active worksheet. To fix the problem, replace the following statement
        Area.Copy Cells(Area.Row + R, Area.Column + C)
with this statement
        Area.Copy PasteRng.Worksheet.Cells(Area.Row + R, Area.Column + C)
This works even if PasteRng is on a worksheet that is not part of the active workbook (but is part of an open workbook).
Finally, if you want to make sure the pasted result is visible, add these statements before 'End Sub'
    PasteRng.Worksheet.Activate
    PasteRng.Show
As noted by Tomek, the Tip says:
"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."
This should be modified as follows:
"If your non-contiguous selection consists of ranges that all come from the same rows or from the same columns (or both), you can copy and paste them using the standard Ctrl+C and Ctrl+V commands."


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.