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: Finding Rows with Values in Two Columns.
by Allen Wyatt
(last updated November 5, 2016)
Adri has a worksheet that has quite a few data records in it (well over 40,000). Two of the columns on each row are supposed to be mutually exclusive—a value can be in column F or in column G, but a value should not be in column F and column G. Adri need a quick way to find any records in which there is a value in both columns F and G so she can rectify these erroneous entries.
The key here is the phrase "on each row." Audri wants to simply look at column F and G on any given row and make sure that there aren't values (any values) in both F and G. Understanding this, there are a number of different ways you can proceed. An easy way is to add a simple formula to column H, such as this:
Assuming you place this formula in cell H2 (just to the right of the cells being examined), the result will be either 0, 1, or 2. If both F2 and G2 are empty, then the result is 0; if either F2 or G2 is empty, then the result is 1; and if neither F2 or G2 is empty, then the result is 2. You can easily sort or filter by the results in column H to find those rows that don't have the proper count.
If you prefer a textual indicator in column H, you can use a formula such as this:
This formula displays "Error" if there is either nothing in F and G or something in both F and G. It only displays "OK" if there is something in either F or G. With the formula in place, you can easily sort or filter to find the errant rows.
Speaking of filters, you can easily apply an AutoFilter that will show you only those rows that have something in both columns F and G. Turn on the AutoFilter tool, and then click the down-arrow at the top of column F. In the resulting drop-down list, choose Show Nonblanks. The number of rows displayed on the screen is reduced according to this specification. When you apply the same criteria to column G, what you are left with is only those rows with non-blank values in both F and G. (If you also want to check those which have nothing in both F and G, you can select Show Blanks for both column F and G.)
ExcelTips is your source for cost-effective Microsoft Excel training. This tip (10628) 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: Finding Rows with Values in Two Columns.
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!
Apply an AutoFilter to a worksheet, and you can quickly forget exactly what that AutoFilter entailed. Here are a couple of ...Discover More
The filtering capabilities of Excel are very helpful when you are working with large sets of data. You can create a custom ...Discover More
Excel limits the number of items that can be shown in an AutoFilter drop-down list. Granted, it is a high limit, but it is a ...Discover More