Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, 2013, 2016, 2019, and Excel in Office 365. 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: Finding Rows with Values in Two Columns.

# Finding Rows with Values in Two Columns

by Allen Wyatt
(last updated March 20, 2021)

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:

```=COUNTA(F2:G2)
```

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:

```=IF(ISBLANK(F2)+ISBLANK(G2)<>1,"Error","OK")
```

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 a filter that will show you only those rows that have something in both columns F and G. Click the Filter tool (on the Data tab of the ribbon) and then click the down-arrow at the top of column F. In the resulting drop-down list, clear the Blanks option; all other check boxes should remain selected. 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 clear all the check boxes except the Blanks option for both column F and G.)

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (10629) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, and Excel in Office 365. You can find a version of this tip for the older menu interface of Excel here: Finding Rows with Values in Two Columns.

##### 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

Leader dots can be a great formatting "flourish" to use in your documents. If the leader dots don't print out correctly, ...

Discover More

Sorting Dates by Month

Sorting by dates is easy, and you end up with a list that is in chronological order. However, things become a bit more ...

Discover More

Password Protecting Specific Columns in a Worksheet

When you are developing a worksheet for others to use, you might want to protect some of the information in that ...

Discover More

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!

##### More ExcelTips (ribbon)

Showing Filter Criteria on a Printout

When you print out a filtered worksheet, you may want some sort of printed record as to what filtering was applied to the ...

Discover More

Performing Calculations while Filtering

The advanced filtering capabilities of Excel allow you to easily perform comparisons and calculations while doing the ...

Discover More

Filtering to a Date Range in the Past

If you have a large number of data records, each with an associated date, you might want to filter that data so you see ...

Discover More
##### Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

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. 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 five more than 5?

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 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.