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

Changing the Default Font

Don't like the font that Word uses for a default in your new documents? You can pick a different font, but the way you ...

Discover More

Changing Your System Date and Time

Need to change the date and time maintained by Windows? It's easy to do using the steps in this tip.

Discover More

Forcing a Worksheet to be Protected Again

Excel allows you to protect your worksheets so they can only be changed as you want to have happen. If you unprotect a ...

Discover More

Dive Deep into Macros! Make Excel do things you thought were impossible, discover techniques you won't find anywhere else, and create powerful automated reports. Bill Jelen and Tracy Syrstad help you instantly visualize information to make it actionable. You’ll find step-by-step instructions, real-world case studies, and 50 workbooks packed with examples and solutions. Check out Microsoft Excel 2019 VBA and Macros 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

Limiting the Number of Characters in a Cell

Need to limit the number of characters that can be entered into a cell? One easy way to do it is through the use of Data ...

Discover More

Ignoring Special Characters when Double-Clicking

If a word contains a special character within it, Excel actually thinks the single word is two words. This tip examines ...

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 4 + 7?

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.