Excel Formula to compare two columns for values, if none populate with data from 3rd column

Abstract: Populate a cell with data from a third column only when two other columns are empty.

Created: 2026-07-27 by
Use the IF and ISBLANK functions together to check if specific cells in two columns are empty. If both are blank, the formula returns a value from a third column; otherwise, it leaves the cell empty or displays a custom message. This approach allows you to automate data population based on conditional logic without manual entry.

Understanding the Logic

The core requirement is to evaluate two conditions simultaneously. You need to determine whether Cell A1 and Cell B1 are both empty. In Excel, an empty cell can be tested using the ISBLANK function. However, ISBLANK only returns TRUE for truly empty cells. If a cell contains a zero-length string (""), ISBLANK returns FALSE. Therefore, you must decide if your "empty" state includes formulas that return "". If you want to treat both truly empty cells and cells with empty strings as blank, use the double unary operator (--) or compare against "" directly. The most robust method for general users is checking if the cell equals an empty string. The logic flows like this: IF (Condition 1 AND Condition 2) THEN Result FROM Column C ELSE Empty.

Constructing the Formula

Assume your data structure is as follows: - Column A: First value set - Column B: Second value set - Column C: Source data to populate if A and B are empty - Column D: Where the result should appear For row 2, the formula in cell D2 would be:
=IF(AND(A2="", B2=""), C2, "")
This formula uses the AND function to combine two checks. The first check verifies if A2 is empty. The second check verifies if B2 is empty. Only when both are true does the IF statement proceed to return the value from C2. If either A2 or B2 contains data, the formula returns an empty string (""). If you prefer to handle cases where cells might contain spaces or invisible characters, you can use the TRIM function inside the check:
=IF(AND(TRIM(A2)="", TRIM(B2)=""), C2, "")
This ensures that cells with only whitespace are also treated as empty.

Applying the Formula to Your Dataset

Once you have entered the formula in the first row of your output column, you need to apply it to the rest of the dataset. Select the cell containing the formula (e.g., D2). Hover over the bottom-right corner of the cell until the cursor turns into a thin black cross, known as the fill handle. Click and drag the fill handle down to the last row of your data. Alternatively, you can copy the cell (Ctrl+C) and paste it (Ctrl+V) into the range below. Excel automatically adjusts the relative references. So, if you drag down to row 10, the formula in D10 will become =IF(AND(A10="", B10=""), C10, ""). This dynamic adjustment is crucial for maintaining accuracy across large datasets. If your source data in Column C is static or referenced from another sheet, ensure that those references remain consistent. If you are pulling data from a different worksheet, you may need to adjust the reference to include the sheet name, such as 'Sheet2'!C2.

Handling Errors and Edge Cases

Sometimes, cells may not appear empty but contain errors like #N/A or #VALUE!. The standard ISBLANK or equality check will fail in these scenarios. To create a more resilient formula, you can wrap the checks in an IFERROR function or use COUNTA. Using COUNTA counts the number of non-empty cells. If COUNTA(A2:B2) equals 0, then both cells are effectively empty. This method ignores text strings that look empty but aren't technically blank.
=IF(COUNTA(A2:B2)=0, C2, "")
This is often cleaner than nested AND statements. It reduces the chance of syntax errors and makes the formula easier to read. Choose the method that best fits how your data is entered. If users manually type nothing, A2="" works. If they use dropdowns that leave cells blank, COUNTA is safer.

Frequently Asked Questions

What if one column has data and the other doesn't?

The formula will return an empty string because the AND condition requires both cells to be empty. If you want to populate the cell if ONLY ONE is empty, change AND to OR in the formula.

How do I handle cells with spaces instead of being truly empty?

Use the TRIM function to remove leading and trailing spaces before comparing. For example, use TRIM(A2)="" to ensure cells with only spaces are treated as empty.

Can I use this formula with VLOOKUP?

Yes, you can nest the IF statement inside a VLOOKUP or use it as the lookup_value argument. However, simpler logic usually performs better in large sheets.

Why is my formula returning #NAME? error?

This error typically occurs if there is a typo in the function name, such as writing "ANd" instead of "AND". Ensure all function names are spelled correctly and enclosed in parentheses.

Is there a way to highlight cells that were populated by this rule?

You can use Conditional Formatting to highlight cells in the result column that match values from Column C. Go to Home > Conditional Formatting > New Rule and define the criteria accordingly.

Latest News

How to Display Output of xterm Command in Terminal Screen using Cron

Resolve the inability to display xterm output in a terminal screen from cron by redirecting logs or using wall instead of insecure X11 workarounds.

Read More
Expose Local Server on VPS Preserving Real Client IPs (OS Level)

Resolve VPS logging showing only gateway IPs by configuring reverse proxies to forward real client addresses via X-Forwarded-For headers.

Read More
How to Clear Recent Files History in Linux without Deleting Actual Files?

Clear recent files history in Linux by deleting ~/.local/share/recently-used.xbel without removing the actual files.

Read More
Best HDD Copy Strategy: Manually Syncing and Rewriting Scratch

Resolve data drift between two 4TB hard drives by using rsync with the --delete flag to manually sync and rewrite scratch data for an exact mirror.

Read More
Understanding Bash Prompt Abbreviations: An Overview

Resolve repetitive typing errors by creating and persisting Bash aliases in the .bashrc file for improved command-line efficiency.

Read More
Free Tools and Methods to Log Real-Time Performance Details in Task Manager

Log real-time CPU and memory metrics to CSV files using Windows Performance Monitor Data Collector Sets to troubleshoot system slowness.

Read More
Contact Qatar Airways Customer Service: Phone Number, Help Center, and More

Resolve urgent Qatar Airways reservation issues like flight changes and baggage claims using the US phone number +1801-855-5905 or online self-service tools.

Read More
Windows 11: Alt Codes Displaying Wrong Characters - Solutions

Resolve Windows 11 Alt codes showing wrong characters by verifying the US keyboard layout and enabling Num Lock.

Read More
Run Programs with Elevated Privileges: A Comprehensive Guide

Eliminates the need to type sudo for frequent administrative tasks by configuring .bashrc aliases or functions.

Read More
Dynamically Changing Dates in Excel Formulas Using Cells

Eliminate manual date updates in Excel by using cell references to create dynamic formulas that automatically adjust calculations when input dates change.

Read More
Granting Edit Access to a Specific Excel Sheet in an Office 365 User Email ID-Based Login

Excel Online lacks native sheet-level permissions, so users must split workbooks or use worksheet protection to isolate edit access for specific tabs.

Read More
Creating Network Load on Local Wi-Fi from One PC

Generate sustained Wi-Fi bandwidth load from a single PC using a VM SFTP server to test router stability and throughput.

Read More
Changing the Default Editor for Batch Files in Windows 11's File Explorer

Resolve the issue of batch files opening in Notepad by changing the default editor to a preferred application like VS Code.

Read More
Gain WiFi Connection Minutes Before Losing it by Changing MAC Address

Bypass MAC address filtering to restore WiFi connectivity temporarily when a device is blocked by network administrators.

Read More
Photos Folders Turned Black: Troubleshooting Picture Applications on Windows

Resolve black screens in Windows Photos by resetting the app, updating graphics drivers, and repairing system files.

Read More
Troubleshooting High CPU Temperature Values: A Step-by-Step Guide

Resolve high CPU temperatures and thermal throttling by monitoring with Speedfan, cleaning dust from cooling components, and replacing degraded thermal paste.

Read More
Make cURL establish TLS connection with CA unknown

Resolve cURL TLS connection failures with unknown or self-signed certificates by using the --insecure flag to bypass CA validation.

Read More
Troubleshooting Incorrect Network Metrics Values in Grafana, Prometheus, InfluxDB, and Telegraf

Fix incorrect network metrics in Grafana, Prometheus, InfluxDB, and Telegraf by verifying interface selection, resolving unit mismatches, and handling counter resets.

Read More
Start Another Terminal Window (cmd.exe) Windows Repair/Troubleshoot

Provides step-by-step instructions to access the Windows Command Prompt via bootable media for advanced system repair and troubleshooting.

Read More
Thinkpad P1 Gen 6: Sudden Thunderbolt 3 Dock USB-C Charging Stopped Working

Resolve sudden Thunderbolt 3 dock USB-C charging and internet failure on ThinkPad P1 Gen 6 by updating firmware, resetting the dock, and adjusting power settings.

Read More
ASUS Windows 11 Laptop: Internet Connection Issue with Hotspot

Resolve ASUS Windows 11 laptop spinning wheel issue when connecting to mobile hotspot by resetting network stack, disabling IPv6, and adjusting power settings.

Read More
Developing iOS Project with Firebase: Logging in and Sending Push Notifications

Integrates Firebase to enable secure user authentication and push notifications in iOS applications.

Read More
Troubleshooting Bash Script with Suspected Issues of Spaces, Dashes, Filenames and Quoting

Resolve Bash script failures caused by word splitting, globbing, and special characters in filenames by applying proper quoting techniques.

Read More
Populating OneDrive Folder for Local Backup without Affecting Remote Files

Prevent OneDrive from deleting remote files during Windows reinstallation by unlinking the account or using symbolic links to isolate local data.

Read More
Force First Frame as Keyframe Without Re-encoding: A Quick Solution

Resolve inaccurate seeking and playback glitches by re-encoding video to ensure the first frame is a valid keyframe.

Read More
Find Information in Database Using WSL (Ubuntu) on Windows-10

Resolve database connection issues from WSL Ubuntu on Windows 10 by configuring client tools and network access to query remote or local servers.

Read More
Configuring a New Router with Different Networks: One Family, One Guest

Resolve IP conflicts and isolate guest traffic by configuring a second router with a distinct subnet via its WAN port.

Read More
Quickly Open Multiple Stock Websites with a Single Command

Solve the problem of manually opening multiple stock research websites by creating a single command to launch them simultaneously on Windows, macOS, or Linux.

Read More
Improved Adobe Acrobat Search Experience: Access Advanced Search with Ease

Access advanced search filters like case sensitivity and regex in Adobe Acrobat by clicking More Options in the Find bar.

Read More
Port Forwarding VM via OpenVPN: A Comprehensive Guide

Configure OpenVPN server and iptables to forward specific ports from VPN clients to a virtual machine's internal IP address.

Read More
Understanding Partitions in the 1980s: A Look Back at MS-DOS and Master Boot Record

Explains how the Master Boot Record and partition table enabled MS-DOS to manage multiple disk volumes on a single physical drive.

Read More
Windows 10 Enterprise: Keyboard Not Detected in Managed Organization with Admin Privileges

Resolve Windows 10 Enterprise keyboard detection failures caused by Group Policy restrictions, driver corruption, or USB enumeration errors.

Read More
Can't Find x86_64 Versions of Applications on MacOS arm64 (M1)

Resolve missing x86_64 app issues on M1 Macs by installing Rosetta 2 and reinstalling apps as universal binaries.

Read More
How to Hide Installation Source for an Android App

Manage Android app installation source visibility by using USB transfers or file managers to reduce browser traces and isolate data via work profiles.

Read More
Connecting Momentus 4200.2 ST9808210A Hard Drive via USB Cable

Resolve inability to access Seagate Momentus 4200.2 ST9808210A hard drive by connecting it via USB using a compatible SATA-to-USB adapter and configuring the disk in Windows.

Read More