Solved Create an empty cell with an Excel IF

Microsoft Excel 2003 (full product)
October 8, 2010 at 10:57:06
Specs: Windows XP
I need to make a chart but I only want to chart the non-empty cells. But for some of the cells I use an IF to automatically fill them with a value or leave the cell empty. I used "" for the empty case but the chart does not see that as empty.
e.g., =IF(LEN(B121)=0,"",B121-6000)
Can anyone suggest the proper entry for the TRUE case in the example to create an empty cell?

See More: Create an empty cell with an Excel IF

Report •

October 8, 2010 at 11:36:25
✔ Best Answer
There really is no way to use a formula to create an "empty" cell since the cell will contain the formula.

Here are 2 methods to create a graph that will ignore the blank cells:

1 - This one I've used in the past:

Create an AutoFilter for your data and select "NonBlanks". Only the visible cells will be graphed.

2 - This one I stole without permission from here and then modified:

Let's say your data resides in A1:A10 and a few of those cells are blank due to your formula.

Enter this in B1 and drag it down to B10:


Enter this in C1 and drag it down to C10: (formula split to fit in this post)


Column C should now contain a contiguous list of the non-blank values from A1:A10.

Graph the values in Column C.

BTW, instead of this...


why not use this?

=IF(B121="", "", B121-6000)

Report •

October 9, 2010 at 13:28:07
Thanks for the input. Here is another idea. In this example column J has the graph Y values (=IF(LEN(B121)=0,"",B121-6000)) and that is where I need an empty cell if B121 is blank.

If I can put my formula for column J (the column with the Y values for the chart) into column O and if there is a way to copy the result of the formula to column J then I can create an IF that will do nothing or copy the result of B121-6000 to J. That way J will have empty cells if B121 is blank.

e.g., Column O would have something like =IF(LEN(B121)="","",COPY(J121,B121-6000))

So is there a "copy" function?

Report •

October 10, 2010 at 06:47:55
Formulas cannot perform actions (e.g. Copy) they can only produce a result within the same cell, based on the inputs to the formula.

The only way to get a completely empty cell based on the result of a formula is to use VBA to set the contents of the cell. VBA can either replace (permanently) a formula that created the blank cell or it can look at the contents of 1 cell and set another one to empty.

This could be done automatically with a worksheet change macro that could monitor (for example) a given column and run every time that column is changed.

However, I still don't see how that will solve your problem. If you have blanks cells in the list of data you are trying to graph, won't they still get graphed?

Since you seem to be willing to try something that involves multiple columns, what is wrong with suggestion # 2 from my previous post?

Report •

Related Solutions

October 12, 2010 at 18:22:51
I never suggested there was something wrong with suggestion #2. I have not tried it yet. I just wanted to find out an answer to my new idea first.

Regarding your other question "won't they still get graphed", the answer is no. If either the x or y cell is blank then it won't graph that if you set "Plot empty cells as" to "Not plotted" in Options/Chart/Active chart.

Report •

October 17, 2010 at 09:17:54
I tried the above #2 method. Maybe I was not clear in my original question. Here is my data:
A1-A10: =IF(G1<>"",G1*10,""), =IF(G2<>"",G2*10,""), etc.
F1-F10: date, =F1+1, =F2+1, etc.
G1-G10: 100, 200, 300, 400, 500, blank, blank, blank, blank, blank

I want F on the X axis and A on the Y axis. But I don't want to graph F or A if A appears blank (or G is blank).

Report •

October 17, 2010 at 16:05:07
I tried Option # 1 and it seemed to work for the example you gave, but not in some other cases.

I used the information in your latest post and got this:

       A   B C D E     F        G
1    1000          01/01/10    100
2    2000          01/02/10    200
3    3000          01/03/10    300
4    4000          01/04/10    400
5    5000          01/05/10    500
6                  01/06/10    
7                  01/08/10    
9                  01/09/10    
10                 01/10/10    

When I graphed it, using a bar graph, I got 5 bars for the first 5 dates, and then just data labels for the rest.

I then selected A1:A10, and used Data...Autofilter to get a drop down arrow.

I pulled down the drop down arrow and choose Non-Blanks.

The graph changed so that it only showed the first 5 dates and the bars for 1000 - 5000.

However, if I add a value in G7, to get 7000 in A7 and use the same filter, I still get a blank for 01/06/10 but only for 01/06/10, not anything beyond 01/07/10.

I don't know if there is a way to graph your data without getting the X axis labels if the blanks are in the middle of the list. Even if I copy the filtered data to another range, Excel adds X axis labels for the dates that don't have values.


Report •

Ask Question