Please Note: This article is written for users of the following Microsoft Excel versions: 97, 2000, 2002, and 2003. If you are using a later version (Excel 2007 or later), this tip may not work for you. For a version of this tip written specifically for later versions of Excel, click here: Removing Cells from a Selected Range.

Removing Cells from a Selected Range

by Allen Wyatt
(last updated May 18, 2013)

2

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.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (3102) applies to Microsoft Excel 97, 2000, 2002, and 2003. You can find a version of this tip for the ribbon interface of Excel (Excel 2007 and later) here: Removing Cells from a Selected Range.

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

AutoFormatting a Document

The AutoFormat feature of Word can be configured to make changes to a variety of conditions in your document. Here's how to ...

Discover More

Quickly Selecting Text

Want a really quick way to select text? Just combine the Shift key with a simple mouse click.

Discover More

Default Font for Page Numbers

Page numbers are a common addition to documents, and a great aid to readers. If you want to easily format page numbers, you ...

Discover More

Solve Real Business Problems Master business modeling and analysis techniques with Excel and transform data into bottom-line results. This hands-on, scenario-focused guide shows you how to use the latest Excel tools to integrate data from multiple tables. Check out Microsoft Excel 2013 Data Analysis and Business Modeling today!

MORE EXCELTIPS (MENU)

Going to the Corners of a Selected Range

When you select a range of cells (particularly if it is a large range of cells), you may not be quite sure if you've selected ...

Discover More

Limiting Scroll Area

If you need to limit the cells that are accessible by the user of a worksheet, VBA can come to the rescue. This doesn't ...

Discover More

Weird Mouse Shortcut

If you like to use the mouse in your worksheet navigation efforts, you'll want to pay attention to this tip. Here you ...

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 for this tip:

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}] in your comment text. You’ll be prompted to upload your image when you submit the comment. 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 eight more than 7?

2014-05-26 02:00:18

Rouhollah

that's pretty nice.
tank's for your help!


2014-03-28 08:13:21

Ed

Hi Allen
This macro is just what I have been looking for and dont see it as well explained anywhere as I see here. Many thanks for the time you dedicate. However this is not working for me the macro runs and I see the popup where I can choose the range to deselect but when I click OK on the popup up the excel sheet just freezes up ... timer wheel keeps spinning unendlessely and program won't respond. Have you had similar feedback ... can you offer a fix?
I use excel 2007... wishing to select the entire sheet and then de-select various cells.
Many thanks
Ed


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.

Links and Sharing
Share