Removing Cells from a Selected Range

Written by Allen Wyatt (last updated August 8, 2020)
This tip applies to Excel 97, 2000, 2002, and 2003


Let's say that you've selected a large range of cells, such as A7:R182. You want to perform some sort of operation on all the cells in this range, except a few. You might wonder how to remove a couple of cells within the range from the selection set, so you hold down the Ctrl key as you click on those cells. That doesn't work; Excel simply unselects the range you previously selected.

There is no way to change this behavior within Excel itself. Instead, you need to turn to other solutions. One is to use a macro, such as the following:

Sub UnSelectSomeCells()
    Dim rSelect As Range
    Dim rUnSelect As Range
    Dim rNew As Range
    Dim rCell As Range

    Set rSelect = Selection
    Set rUnSelect = Application.InputBox( _
      "What cells do you want to exclude?", Type:=8)

    For Each rCell In rSelect
        If Intersect(rCell, rUnSelect) Is Nothing Then
            If rNew Is Nothing Then
                Set rNew = rCell
            Else
                Set rNew = Union(rNew, rCell)
            End If
        End If
    Next
    rNew.Select

    Set rCell = Nothing
    Set rSelect = Nothing
    Set rUnSelect = Nothing
    Set rNew = Nothing
End Sub

To use the macro, select the entire range you want to start with, such as A7:R182. Then run the macro. You are asked to choose the cells to be unselected. You can do so by simply selecting the cells with the mouse, holding down the Shift key as you click on each one. When you dismiss the input box, the selection you started with is modified to exclude the cells you selected.

If you prefer to not use your own macros, you can find help for deselecting cells in a selected range by using third-party tools, such as the ASAP Utilities. You can find their Excel tools at this Web page:

http://www.asap-utilities.com/asap-utilities-excel-tools.php

The tool applicable to this tip is the Select tool.

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 (3102) applies to Microsoft Excel 97, 2000, 2002, and 2003.

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

Using the Fill Handle from the Keyboard

The fill handle can save a huge amount of time when you are editing a worksheet. If you are really good at using the ...

Discover More

Quick Recall of Table Formats

Got a table that you use over and over again? One way you can make quick work of such repetition is to save the table in ...

Discover More

Changing Macro Cell References Based on Edits

Place a cell reference in a macro, modify the structure of your worksheet, and you may soon find that the cell reference ...

Discover More

Create Custom Apps with VBA! Discover how to extend the capabilities of Office 2013 (Word, Excel, PowerPoint, Outlook, and Access) with VBA programming, using it for writing macros, automating Office applications, and creating custom applications. Check out Mastering VBA for Office 2013 today!

More ExcelTips (menu)

Finding the End of the Worksheet

Want a quick way to get to the last cell in your worksheet? This tip provides a handy shortcut and a potential "gotcha."

Discover More

Jumping to the Real Last Cell

Jumping to the last cell in a worksheet should be easy, but you may not always get the results that you expect. This tip ...

Discover More

Scrolling Up and Down

Need an easy way to move through a spreadsheet using a mouse? Here are a couple of ideas.

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 two more than 7?

There are currently no comments for this tip. (Be the first to leave your comment—just use the simple form above!)


This Site

Got a version of Excel that uses the menu interface (Excel 97, Excel 2000, Excel 2002, or Excel 2003)? This site is for you! If you use a later version of Excel, visit our ExcelTips site focusing on the ribbon 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.