Excel if column is not empty

Explanation 

In this example, the goal is to create a formula that will return «Done» in column E when a cell in column D contains a value. In other words, if the cell in column D is «not blank», then the formula should return «Done». In the worksheet shown, column D is is used to record the date a task was completed. Therefore, if the column contains a date (i.e. is  not blank), we can assume the task is complete. This problem can be solved with the IF function alone or with the IF function and the ISBLANK function. It can also be solved with the LEN function. All three approaches are explained below.

IF function

The IF function runs a logical test and returns one value for a TRUE result, and another value for a FALSE result. You can use IF to test for a blank cell like this:

=IF(A1="",TRUE) // IF A1 is blank
=IF(A1<>"",TRUE) // IF A1 is not blank

In the first example, we test if A1 is empty with =»». In the second example, the <> symbol is a logical operator that means «not equal to», so the expression A1<>»» means A1 is «not empty». In the worksheet shown, we use the second idea in cell E5 like this:

=IF(D5<>"","Done","")

If D5 is «not empty», the result is «Done». If D5 is empty, IF returns an empty string («») which displays as nothing. As the formula is copied down, it returns «Done» only when a cell in column D contains a value. To display both «Done» and «Not done», you can adjust the formula like this:

=IF(D5<>"","Done","Not done")

ISBLANK function

Another way to solve this problem is with the ISBLANK function. The ISBLANK function returns TRUE when a cell is empty and FALSE if not. To use ISBLANK directly, you can rewrite the formula like this:

=IF(ISBLANK(D5),"","Done")

Notice the TRUE and FALSE results have been swapped. The logic now is if cell D5 is blank. To maintain the original logic, you can nest ISBLANK inside the NOT function like this:

=IF(NOT(ISBLANK(D5)),"Done","")

The NOT function simply reverses the result returned by ISBLANK.

LEN function

One problem with testing for blank cells in Excel is that ISBLANK(A1) or A1=»» will both return FALSE if A1 contains a formula that returns an empty string. In other words, if a formula returns an empty string in a cell, Excel interprets the cell as «not empty». To work around this problem, you can use the LEN function to test for characters in a cell like this:

=IF(LEN(A1)>0,TRUE)

This is a much more literal formula. We are not asking Excel if A1 is blank, we are literally counting the characters in A1. The LEN function will return a positive number only when a cell contains actual characters.

Excel for Microsoft 365 Excel for Microsoft 365 for Mac Excel 2021 Excel 2021 for Mac Excel 2019 Excel 2019 for Mac Excel 2016 Excel 2016 for Mac Excel 2013 Excel 2010 Excel 2007 Excel for Mac 2011 More…Less

Sometimes you need to check if a cell is blank, generally because you might not want a formula to display a result without input.

Formula in cell E2 is =IF(D2=1,"Yes",IF(D2=2,"No","Maybe"))

In this case we’re using IF with the ISBLANK function:

  • =IF(ISBLANK(D2),»Blank»,»Not Blank»)

Which says IF(D2 is blank, then return «Blank», otherwise return «Not Blank»). You could just as easily use your own formula for the «Not Blank» condition as well. In the next example we’re using «» instead of ISBLANK. The «» essentially means «nothing».

Checking if a cell is blank - Formula in cell E2 is =IF(ISBLANK(D2),"Blank","Not Blank")

=IF(D3=»»,»Blank»,»Not Blank»)

This formula says IF(D3 is nothing, then return «Blank», otherwise «Not Blank»). Here is an example of a very common method of using «» to prevent a formula from calculating if a dependent cell is blank:

  • =IF(D3=»»,»»,YourFormula())

    IF(D3 is nothing, then return nothing, otherwise calculate your formula).

Need more help?

Want more options?

Explore subscription benefits, browse training courses, learn how to secure your device, and more.

Communities help you ask and answer questions, give feedback, and hear from experts with rich knowledge.


You can use the following formula in Excel to perform some task if a cell is not empty:

=IF(A1<>"", Value_If_Not_Empty, Value_If_Empty)

This particular formula checks if cell A1 is empty.

If it is not empty, then Value_If_Not_Empty is returned.

If it is empty, then Value_If_Empty is returned.

The following example shows how to use this formula in practice.

Example: Use “If Not Empty” Formula in Excel

Suppose we have the following dataset in Excel that contains information about various basketball teams:

We can use the following formula to return a value of “Team Exists” if the cell in column A is not empty.

Otherwise, we’ll return a value of “Does Not Exist”:

=IF(A2<>"", "Team Exists", "Does Not Exist")

The following screenshot shows how to use this formula in practice:

If the team name is not empty in column A, then “Team Exists” is returned.

Otherwise, “Does Not Exist” is returned.

If we’d like, we could also return numeric values instead of character values.

For example, we could use the following formula to return the value of the points column divided by two if the cell in column A is not empty.

Otherwise, we’ll return an empty value:

=IF(A2<>"", B2/2, "")

The following screenshot shows how to use this formula in practice:

Excel formula for "if not empty"

If the team name is not empty in column A, then we return the value in the points column multiplied by two.

Otherwise, we return an empty value.

Additional Resources

The following tutorials explain how to perform other common tasks in Excel:

How to Replace Blank Cells with Zero in Excel
How to Replace #N/A Values in Excel
How to Ignore #VALUE! Error in Excel

How do I conditionally format a cell so if not blank it is grey?

I tried to do ‘not equal’, but it didn’t work.

I am using Windows Office 2003 with Windows XP at work. I don’t see the same feature as below:

enter image description here

What I have tried so far:

enter image description here

Edit: Figured what was wrong. In my production (actual work Excel), they were filled with white color. It wasn’t my Excel file, so I was not aware of this before.

pnuts's user avatar

pnuts

58k11 gold badges85 silver badges137 bronze badges

asked May 13, 2013 at 21:03

George's user avatar

5

Does this work for you:

enter image description here

You find this dialog on the Home ribbon, under the Styles group, the Conditional Formatting menu, New rule....

answered May 13, 2013 at 21:07

Floris's user avatar

FlorisFloris

45.7k6 gold badges70 silver badges122 bronze badges

5

You can use Conditional formatting with the option «Formula Is». One possible formula is

=NOT(ISBLANK($B1))

enter image description here

Another possible formula is

=$B1<>""

enter image description here

answered May 14, 2013 at 8:03

teylyn's user avatar

teylynteylyn

34.1k4 gold badges52 silver badges72 bronze badges

4

In Excel 2003 you should be able to create a formatting rule like:

=A1<>"" and then drag/copy this to other cells as needed.

If that doesn’t work, try =Len(A1)>0.

If there may be spaces in the cell which you will consider blank, then do:

=Len(Trim(A1))>0

Let me know if you can’t get any of these to work. I have an old machine running XP and Office 2003, I can fire it up to troubleshoot if needed.

answered May 14, 2013 at 2:10

David Zemens's user avatar

David ZemensDavid Zemens

52.8k11 gold badges79 silver badges129 bronze badges

1

This worked for me:

=NOT(ISBLANK(A1))

I wanted a box around NOT Blank cells in an entire worksheet.
Use the $A1 if you want the WHOLE ROW formatted based on the A1, B1, etc result.

Thanks!

answered Dec 26, 2013 at 16:16

WayneGrantham's user avatar

This method works for Excel 2016, and calculates on cell value, so can be used on formula arrays (i.e. it will ignore blank cells that contain a formula).

  • Highlight the range.
  • Home > Conditional Formatting > New Rule > Use a Formula.
  • Enter «=LEN(#)>0» (where ‘#’ is the upper-left-most cell in your range).
  • Alter the formatting to suit your preference.

Note: Len(#)>0 be altered to only select cell values above a certain length.

Note 2: ‘#’ must not be an absolute reference (i.e. shouldn’t contain ‘$’).

answered May 23, 2018 at 12:48

Finger Picking Good's user avatar

An equivalent result, «other things being equal», would be to format all cells grey and then use Go To Special to select the blank cells prior to removing their grey highlighting.

answered May 14, 2013 at 8:53

pnuts's user avatar

pnutspnuts

58k11 gold badges85 silver badges137 bronze badges

Содержание

  1. ISBLANK Function
  2. Related functions
  3. Summary
  4. Purpose
  5. Return value
  6. Arguments
  7. Syntax
  8. Usage notes
  9. Examples
  10. Is not blank
  11. Empty string syntax
  12. Empty strings
  13. How to check if a column is empty?
  14. 2 Answers 2
  15. Check Columns If Empty (or Blank)
  16. IF Cell is Blank (Empty) using IF + ISBLANK
  17. Formula to Check IF a Cell is Blank or Not (Empty)
  18. Alternate Formula
  19. Premium Excel Course Now Available!
  20. Build Professional — Unbreakable — Forms in Excel
  21. 45 Tutorials — 5+ Hours — Downloadable Excel Files
  22. Check if Cell is Empty or Not in Excel
  23. Sections:
  24. Check if a Cell is Empty or Not — Method 1
  25. Reverse the True/False Output
  26. Check if a Cell is Empty or Not — Method 2
  27. Reverse the Check
  28. Notes
  29. If cell is not blank
  30. Related functions
  31. Summary
  32. Generic formula
  33. Explanation
  34. IF function
  35. ISBLANK function
  36. LEN function

ISBLANK Function

Summary

The Excel ISBLANK function returns TRUE when a cell is empty, and FALSE when a cell is not empty. For example, if A1 contains «apple», ISBLANK(A1) returns FALSE.

Purpose

Return value

Arguments

Syntax

Usage notes

The ISBLANK function returns TRUE when a cell is empty, and FALSE when a cell is not empty. For example, if A1 contains «apple», ISBLANK(A1) returns FALSE. Use the ISBLANK function to test if a cell is empty or not. ISBLANK function takes one argument, value, which is a cell reference like A1.

The word «blank» is somewhat misleading in Excel, because a cell that contains only space will look blank but not be empty. In general, it is best to think of ISBLANK to mean «is empty» since it will return FALSE when a cell looks blank but is not empty.

Examples

If cell A1 contains nothing at all, the ISBLANK function will return TRUE:

If cell A1 contains any value, or any formula, the ISBLANK function will return FALSE:

Is not blank

To test if a cell is not blank, nest ISBLANK inside the NOT function like this:

The above formula will return TRUE when a cell is not empty, and FALSE when a cell is empty.

Empty string syntax

Many formulas will use an abbreviated syntax to test for empty cells, instead of the ISBLANK function. This syntax uses an empty string («») with Excel’s math operators «=» or «<>«. For example, to test if A1 is empty, you can use:

To test if A1 is not empty:

This syntax can be used interchangeably with ISBLANK. For example, inside the IF function:

is equivalent to:

Likewise, the formula:

Both will return result1 when A1 is not empty, and result2 when A1 is empty.

Empty strings

If a cell contains any formula, the ISBLANK function and the alternatives above will return FALSE, even if the formula returns an empty string («»). This can cause problems when the goal is to count or process blank cells that include empty strings.

One workaround is to use the LEN function to test for a length of zero. For example, the formula below will return TRUE if A1 is empty or contains a formula that returns an empty string:

So, inside the IF function, you can use LEN like this:

You can use this same approach to count cells that are not blank.

Источник

How to check if a column is empty?

I’m attempting to check if each column is empty. I need it for more calculations.

I need to do it for nine of the columns f through n and for each I need that value as a Boolean afterwards which is why I made it the way I did based on a tutorial.

I’m trying to get a message that tells me if a column is empty.

2 Answers 2

Essentially you are checking nine columns for rows 1 through 200 if they are empty or not. Using a loop you can call some custom function (see below) to make the checks.

And the sample output on the immediate window

With the following helper functions in a module

Check Columns If Empty (or Blank)

Tips

Whenever you need to create a ton of variables holding the same data type, you should consider using a data structure e.g. an array, a collection, a dictionary. etc. Then you can loop through the elements of the data structure and/or easily access individual elements.

When you do Dim cell As Range it actually means

Similarly, when you do Dim fIsEmpty As Boolean , it actually means

When declaring a variable, it is always assigned a default value like in both for-mentioned cases. In the first case, it is Nothing , while in the second case it is False i.e. doing fIsEmpty = False is not necessary. If it helps with your understanding of the code, you can keep doing it, there’s no harm done except that the code is longer.

When looping through the cells of a range, you should consider doing it in this way:

Note the .Cells . By doing this, the code will become more readable and you’ll avoid errors occurring when VBA ‘might decide’ that it is .Rows or .Columns (the latter is used in the following codes) or whatnot.

Instead of If IsEmpty(cell) = True Then you can simply do:

Again, If it helps with your understanding of the code, you can keep doing it, there’s no harm done except that the code is longer.

Empty

You can efficiently check if all the cells in a range are empty by using Application.CountA in the following way:

Blank

A cell is considered blank if it is either empty, it contains the formula =»» , it contains a single quote ‘ or whatnot (can’t think of anything else).

Источник

IF Cell is Blank (Empty) using IF + ISBLANK

In Excel, if you want to check if a cell is blank or not, you can use a combination formula of IF and ISBLANK. These two formulas work in a way where ISBLANK checks for the cell value and then IF returns a meaningful full message (specified by you) in return.

In the following example, you have a list of numbers where you have a few cells blank.

Formula to Check IF a Cell is Blank or Not (Empty)

  1. First, in cell B1, enter IF in the cell.
  2. Now, in the first argument, enter the ISBLANK and refer to cell A1 and enter the closing parentheses.
  3. Next, in the second argument, use the “Blank” value.
  4. After that, in the third argument, use “Non-Blank”.
  5. In the end, close the function, hit enter, and drag the formula up to the last value that you have in the list.

As you can see, we have the value “Blank” for the cell where the cell is empty in column A.

Now let’s understand this formula. In the first part where we have the ISBLANK which checks if the cells are blank or not.

And, after that, if the value returned by the ISBLANK is TRUE, IF will return “Blank”, and if the value returned by the ISBLANK is FALSE IF will return “Non_Blank”.

Alternate Formula

You can also use an alternate formula where you just need to use the IF function. Now in the function, you just need to specify the cell where you want to test the condition and then use an equal operator with the blank value to create a condition to test.

And you just need to specify two values that you want to get the condition TRUE or FALSE.

Источник

Premium Excel Course Now Available!

Build Professional — Unbreakable — Forms in Excel

45 Tutorials — 5+ Hours — Downloadable Excel Files

Check if Cell is Empty or Not in Excel

BLACK FRIDAY SALE (65%-80% Off)

Excel Courses Online
Video Lessons Excel Guides

How to check if a cell is empty or is not empty in Excel; this tutorial shows you a couple different ways to do this.

Sections:

Check if a Cell is Empty or Not — Method 1

Use the ISBLANK() function.

This will return TRUE if the cell is empty or FALSE if the cell is not empty.

Here, cell A1 is being checked, which is empty.

When the cell is not empty, it looks like this:

FALSE is output because cell B1 is not empty.

Reverse the True/False Output

Some formulas need to have TRUE or FALSE reversed in order to work correctly; to do this, use the NOT() function.

Whereas ISBLANK() output a TRUE for cell A1, the NOT() function reversed that and changed it to FALSE.

The same works for changing FALSE to TRUE.

Check if a Cell is Empty or Not — Method 2

You can also use an IF statement to check if a cell is empty.

The function checks if this part is true: A1=»» which checks if A1 is equal to nothing.

When there is something in the cell, it works like this:

Cell B1 is not empty so we get a Not Empty result.

In this example I set the IF statement to output «Empty» or «Not Empty» but you can change it to whatever you like.

Reverse the Check

The example above checked if the cell was empty, but you can also check if the cell is not empty.

There are a few different ways to do this, but I will show you a simple and easy method here.

Notice the check this time is A1<>«» and that says «is cell A1 not equal to nothing.» It sounds confusing but just remember that <> is basically the reverse of =.

I also had to switch the «Empty» and «Not Empty» in order to get the correct result since we are now checking if the cell is not empty.

As you can see, it outputs the same result as the previous example, just like it should.

Using <> instead of = merely reverses it, making a TRUE become a FALSE and a FALSE become a TRUE, which is why «Empty» and «Not Empty» had to be reversed in order to still output the correct result.

Notes

It may seem useless to return TRUE or FALSE like in the first method, but remember that many functions in Excel, including IF(), AND(), and OR() all rely on results that are either TRUE or FALSE.

Checking for blanks and returning TRUE or FALSE is a simple concept but it can get a bit confusing in Excel, especially when you have complex formulas that rely on the result of the formulas in this tutorial. Save this tutorial and work with the attached sample file and you will have it down in no time.

Make sure to download the attached sample file to work with these examples in Excel.

Источник

If cell is not blank

Summary

To test if a cell is not blank (i.e. has content), you can use a formula based on the IF function. In the example shown, the formula in cell E5 is:

As the formula is copied down it returns «Done» when a cell in column D is not blank and an empty string («») if the cell is blank.

Generic formula

Explanation

In this example, the goal is to create a formula that will return «Done» in column E when a cell in column D contains a value. In other words, if the cell in column D is «not blank», then the formula should return «Done». In the worksheet shown, column D is is used to record the date a task was completed. Therefore, if the column contains a date (i.e. is not blank), we can assume the task is complete. This problem can be solved with the IF function alone or with the IF function and the ISBLANK function. It can also be solved with the LEN function. All three approaches are explained below.

IF function

The IF function runs a logical test and returns one value for a TRUE result, and another value for a FALSE result. You can use IF to test for a blank cell like this:

In the first example, we test if A1 is empty with =»». In the second example, the <> symbol is a logical operator that means «not equal to», so the expression A1<>«» means A1 is «not empty». In the worksheet shown, we use the second idea in cell E5 like this:

If D5 is «not empty», the result is «Done». If D5 is empty, IF returns an empty string («») which displays as nothing. As the formula is copied down, it returns «Done» only when a cell in column D contains a value. To display both «Done» and «Not done», you can adjust the formula like this:

ISBLANK function

Another way to solve this problem is with the ISBLANK function. The ISBLANK function returns TRUE when a cell is empty and FALSE if not. To use ISBLANK directly, you can rewrite the formula like this:

Notice the TRUE and FALSE results have been swapped. The logic now is if cell D5 is blank. To maintain the original logic, you can nest ISBLANK inside the NOT function like this:

The NOT function simply reverses the result returned by ISBLANK.

LEN function

One problem with testing for blank cells in Excel is that ISBLANK(A1) or A1=»» will both return FALSE if A1 contains a formula that returns an empty string. In other words, if a formula returns an empty string in a cell, Excel interprets the cell as «not empty». To work around this problem, you can use the LEN function to test for characters in a cell like this:

This is a much more literal formula. We are not asking Excel if A1 is blank, we are literally counting the characters in A1. The LEN function will return a positive number only when a cell contains actual characters.

Источник

Like this post? Please share to your friends:
  • Excel if color macro
  • Excel if check for text
  • Excel if check for error
  • Excel if character is a number
  • Excel if cells do not contain text