To make Google Sheets do something when a cell is not empty, use an IF test such as =IF(A2<>"","Has a value","Empty"). It returns “Has a value” when A2 contains something and “Empty” when it is blank or contains a formula that returns an empty string.
What “not empty” means in Google Sheets
In a spreadsheet, “not empty” can mean different things. A cell may be genuinely unused, contain a number or text, contain a formula whose displayed result is blank, or contain only spaces. The right test depends on which of these cases should count as filled.
The usual comparison, A2<>"", tests whether the cell’s value differs from an empty string. It works well for common data-entry tasks: text, numbers, dates, and a value of zero all count as present. A formula that displays an empty string is treated as empty by this comparison, which is often helpful when a sheet uses formulas to hide unused rows.
Spaces are a frequent source of confusion. A cell containing one or more ordinary spaces is not equal to an empty string, even though it may look empty on screen. Likewise, formatting such as a background color or border does not make a cell nonempty; the test concerns its value, not its appearance.
Use IF for a basic not-empty test
Suppose A2 contains a task name and B2 should show a status. With the value to test in A2, enter this formula in B2:
=IF(A2<>"","Complete","Waiting for a task")
The first argument is the condition. A2<>”” means “A2 is not equal to an empty string.” The second argument is returned when that condition is true, and the third is returned when it is false. Replace the status text with any result that suits the sheet, including a number or another calculation.
For example, if A2 contains “Send invoice,” the formula returns “Complete.” If A2 is blank, it returns “Waiting for a task.” The formula does not change A2; it displays an answer in B2. To apply the same test to later rows, copy or drag the formula down. Google Sheets adjusts the relative reference from A2 to A3, A4, and so on.
You can also leave the output blank when the tested cell is blank. With the input in A2, use this in B2:
=IF(A2<>"","Ready","")
This is useful for keeping reports tidy: B2 displays “Ready” only when A2 has a value. The empty-string result is a formula result, however, not a truly unused cell. That difference matters for some counting and blank-checking functions.
Distinguish a truly blank cell from an empty-looking one
ISBLANK asks whether a cell is genuinely empty. It returns TRUE only when the cell has no value or formula in it. If A2 contains a formula that returns an empty string, ISBLANK(A2) returns FALSE because the cell still contains a formula. Use it when the distinction between unused and formula-filled cells matters.
With the cell being checked in A2, this formula in B2 labels the two cases:
=IF(ISBLANK(A2),"Truly blank","Contains something")
For a check that ignores cells containing only ordinary spaces, test the trimmed content instead. With the input in A2, use:
=IF(LEN(TRIM(A2&""))>0,"Has content","Blank or spaces")
The expression converts the value to text, removes leading and trailing spaces, and checks whether any characters remain. A number such as 0 becomes the text “0,” so it still counts as content. TRIM also reduces repeated spaces between words. This approach is helpful for pasted or manually entered text, but it is not a universal cleanup tool for every invisible character; unusual spaces copied from websites may need separate data cleaning.
Use the test in calculations and row logic
A not-empty condition can control a calculation as well as a label. For example, imagine A2 contains a product name, B2 its quantity, and C2 its unit price. To calculate a line total only when the product name is present, put this formula in D2:
=IF(A2<>"",B2*C2,"")
If A2 says “Notebook,” B2 is 3, and C2 is 4, D2 displays 12. If A2 is empty, D2 appears blank instead of showing a zero or an incomplete calculation. This condition checks only A2; if the quantity and price might also be missing, add checks for those cells or validate the inputs separately.
For multiple rows, enter the formula in the first output row and fill it down. Keep the references relative when each row should check its own input. If every row must check the same fixed cell, use an absolute reference such as $A$2; in Google Sheets, dollar signs keep that row or column fixed when a formula is copied.
To return complete rows for which column A is not empty, use FILTER. If the data occupies A2:C100 and column A is the required field, enter this formula in an empty area outside that range:
=FILTER(A2:C100,A2:A100<>"")
FILTER returns the matching rows and updates as the source data changes. If no rows match, FILTER returns an error indicating that no matches were found. Choose an output area with enough room for the results to expand, and avoid placing other content where the results need to appear.
Count nonempty cells carefully
For a basic count, COUNTA counts cells that contain values, including text, numbers, and formulas. If the range is A2:A100, enter this in a separate cell:
=COUNTA(A2:A100)
COUNTA is convenient when every formula-filled cell should count as occupied. Be aware that cells containing formulas that return an empty string may still be counted, as can cells with spaces. If the goal is to count cells with visible content while ignoring formula-generated empty strings and ordinary spaces, use a length-and-trim test instead. With the data in A2:A100, enter:
=SUMPRODUCT(--(LEN(TRIM(A2:A100&""))>0))
This counts entries that leave at least one character after trimming. For a small list, compare the result with the data manually once, especially if values include unusual whitespace or formulas. Choosing a counting rule explicitly prevents a count from appearing inconsistent with what the sheet seems to display.
Choose the right test for your sheet
The simplest formula is usually the best one, provided it matches what “filled” means in your workflow. Use these practical guidelines:
- Use
A2<>""for most status labels, conditional calculations, and rows where formula results that display as blank should be treated as empty. - Use
ISBLANK(A2)when you need to know whether the cell itself is genuinely unused, rather than whether it looks empty. - Use a TRIM-and-LEN test when a cell containing only ordinary spaces should count as empty.
- Use COUNTA for a quick count when formulas and space-only entries should count as occupied; choose a more specific test when they should not.
Consider the purpose of the formula, too. A task tracker might define any entered task name as enough to show “Ready.” An order sheet may need to require both a product and a quantity before calculating a total. A report may want formula-generated empty strings excluded from visible counts. Writing down the intended rule before selecting a function helps avoid results that are technically correct but surprising to the people using the sheet.
Common problems and how to fix them
- A cell looks blank but triggers the formula: Check whether it contains spaces or an invisible character. Try the TRIM-and-LEN version for ordinary spaces, or remove and re-enter the value.
- A blank-looking formula cell is counted: The cell is not truly empty; it contains a formula. Decide whether your task concerns cell contents or the displayed result, then use ISBLANK, a comparison with an empty string, or a visible-content test accordingly.
- Zero is treated as present: That is expected with
A2<>"". Zero is a value, not a blank. If zero should count as missing for your particular task, test for zero explicitly as well as for emptiness. - The formula shows an error or is rejected: Check that the cell references and quotation marks are paired correctly. Google Sheets formulas commonly use commas between arguments, but the spreadsheet’s locale can affect formula separators. Check the Locale setting under File > Settings if your sheet expects a different separator.
- The formula is in the wrong row: When copying a formula, confirm that its reference moved with the intended input row. Use dollar signs only for references that should remain fixed.
Google Sheets compared with Excel
The basic IF, ISBLANK, LEN, TRIM, COUNTA, SUMPRODUCT, and FILTER examples here are Google Sheets formulas. Excel has functions with these names and similar behavior, but this page’s instructions and examples are for Google Sheets in a web browser. Formula separators can depend on locale in either spreadsheet program, so a comma-separated formula may need semicolons in some settings.
For formatting rather than a text label, Google Sheets can visually mark nonempty cells. Select the range, then choose Format > Conditional formatting. In the side panel, set the rule to “Is not empty,” choose the formatting style, and select Done. This changes how matching cells look; it does not write a value into them. Excel has its own conditional-formatting interface, so do not assume the Google Sheets menu path is the same there.
Frequently Asked Questions
What is the Google Sheets formula for if a cell is not empty?
With the cell to test in A2, use =IF(A2<>"","Not empty","Empty"). Change the two result arguments to whatever you want the formula to display or calculate.
Does IF treat a formula that returns an empty string as blank?
A comparison such as A2<>"" treats a formula result of "" as empty for this test. ISBLANK does not: the cell contains a formula, even if the displayed result looks blank.
How do I ignore spaces when checking whether a cell is empty?
With the input in A2, use =LEN(TRIM(A2&""))>0 as a TRUE-or-FALSE test. It returns FALSE for a blank cell or one containing only ordinary spaces.
How can I show a blank result when the input is empty?
With the input in A2, use =IF(A2<>"","Your result",""). The final pair of quotation marks tells IF to display an empty string when A2 is empty.
Can I highlight cells that are not empty without a formula?
Yes. Select the range and choose Format > Conditional formatting, then select the “Is not empty” rule, choose a style, and click Done. This applies visual formatting without changing the cell values.
Related
- How to Keep Leading Zeros in Excel as Text or Numbers
- Leading Zeros in Excel: How to Keep Them
- How to Keep a Running Average in Excel Automatically
Try it: the Date Difference Calculator: days, months, years and weekdays between two dates, with the DATEDIF formulas.
More in How-to basics
- Excel Goal Seek Keyboard Shortcut and How to Use ItIn Excel for Microsoft 365 on Windows, the Goal Seek keyboard sequence is Alt+A, W, G; press each…
- How to Schedule an Email in Outlook on the WebTo schedule an email in Outlook on the web, write your message, select the arrow beside Send, choose…
- How to Insert a Citation Placeholder in WordTo insert a citation placeholder in Word for Microsoft 365 on Windows, place the cursor where the citation…
- Google Sheets IF Statement With Dropdown: ExamplesYes. In Google Sheets, an IF formula can read the value selected in a dropdown and return a…
- How to Archive Emails in New Outlook 365 Without DeletingTo archive emails in new Outlook 365, select the message or messages and choose Archive on the toolbar.…
- How to Add a Shared Mailbox in Microsoft OutlookTo add a shared mailbox in Outlook, first ask your Microsoft 365 or Exchange administrator to grant your…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.