Please Note: This article is written for users of the following Microsoft Excel versions: 2007 and 2010. If you are using an earlier version (Excel 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Excel, click here: Removing Cells from a Selected Range.
by Allen Wyatt
(last updated March 10, 2016)
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:
The tool applicable to this tip is the Select tool.
ExcelTips is your source for cost-effective Microsoft Excel training. This tip (12457) applies to Microsoft Excel 2007 and 2010. You can find a version of this tip for the older menu interface of Excel here: Removing Cells from a Selected Range.
Save Time and Supercharge Excel! Automate virtually any routine task and save yourself hours, days, maybe even weeks. Then, learn how to make Excel do things you thought were simply impossible! Mastering advanced Excel macros has never been easier. Check out Excel 2010 VBA and Macros today!
Got a worksheet in which there may be entire columns that are duplicates of each other? If you want to delete those ...Discover More
Sometimes the data in a worksheet isn't in the exact format desired. If you want to dividie your values by 1,000, there ...Discover More
Need to get rid of spaces in a range of cells? There are two ways you can approach the task, as described here.Discover More
FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
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.