Email:      Pass:    Pass?

Free Excel Forum

Exclude Empty Cells

Forum Register
Search Excel Forum Posts, Tutorials, Macros, Tips, and More

I have this calculation which works fine if all cells have a value. But it will happen that cells in the range are empty.

=SUMPRODUCT(--(1*LEFT('Courses input'!C4:D6,1)-C3<=0), --(1*MID('Courses input'!C4:D6,3,1)>=2))/E3

What can i do to exclude empty cells in the range from calculation?

Similar Excel Video Tutorials

Helpful Excel Macros

Highlight Cells with Text or Formulas (non-empty cells)
- This macro will highlight all cells in excel which are not empty. This means that if a cell contains formulas, text, nu
Delete Rows in Excel if Completely Empty
- This macro will delete only completely blank rows in an excel spreadsheet. It allows you to make a selection of rows, ru
Delete Empty or 'Broken' Named Ranges (#REF!)
- This macro will delete named ranges which refer to empty or #REF! ranges. This means that if a named range has been 'br
Delete Empty Columns
- This macro will delete columns which are completely empty. This means that if there is no data within the entire column
Delete Blank Rows in Excel
- This is a macro which will delete blank rows in excel. This version will delete an entire row if there is a blank cell

Similar Topics


would you be so kind and assist me with updating my formula to not count empty cells?


I would like to have amount of unique values based on another criteria. Row G would be G2:G2000, however cells below G51 are currently empty and formula would show an error.

Thank you very much.

I have a column of numbers where empty cells are randomly inserted between populated cells. I need to locate an empty cell and insert a calculation that would average the existing numbers in the cells directly above and below and place the result in the empty cell.
Column A
Row 1 5
Row 2 10
Row 3 Empty
Row 4 50
Row 5 Empty
Row 6 Empty
Row 7 Empty
Row 8 250

The results should be A3=30, A5=100, A6=150, A7=200

I can obviously write a different formula to figure out each empty cell value but I would like one "universal" formula that I can place in cell B2 and drag down.

Any help is appreciated. Thanks!


so i have a formula that wont work in my macro but if i cut and paste it into the cell i want it to work in, it works fine....

Range("B2").Formula = "=IF(ISERROR(IF(MATCH(Courses!A1,Master!B1:B700),Courses!A1,"")),"",IF(MATCH(Courses!A1,Master!B1:B7 00),Courses!A1,""))"

this one works and its the same format ....
Range("C2").Formula = "=IF(SUMPRODUCT(--(Updated!$A$1:$A$700=$A$1)*--(Updated!$B$1:$B$700=B2),Updated!$E$1:$E$700),SUMPRODUCT(--(Updated!$A$1:$A$700=$A$1)*--(Updated!$B$1:$B$700=B2),Updated!$E$1:$E$700),(SUMPRODUCT(--(Master!$A$1:$A$700=$A$1)*--(Master!$B$1:$B$700=B2),Master!$C$1:$C$700)))"

what am i doing wrong? dont worry about the second formula, it works fine but the first one is giving me issues only in my macro .. the only other difference and i dont know if it matters or not but b2 is text and c2 is a number

Courses!A1 contains a course name that needs to be found on the master sheet anywhere in b1:b700 if its not there it puts a blank cell...and theres no space on courses!a1 if its showing up that way .. :-)

Does anyone know how to exclude cells from a SUMPRODUCT range?

I am using SUMPRODUCT to count how many groups of "X" occur in a range of cells.

1 ___X X _____X X X____________

eg: =SUMPRODUCT(--(A1:Q1="X"),--(B1:R1"X"))

This returns the value 2 which is correct.

However I want to exclude,column 'J' from the formula and still have the result return the value 2.

1 ___ X X ____X __X_____________

How can I modify the formula to exclude certain cells?

Hello everyone.
Trying to get some statistics out of my golf!

My problem is i have in the cells 412,402,512 and so on, every number is a seperate stat.

I use this to count the first number.
=SUMPRODUCT(--(LEFT('Courses input'!B4:D4,1)="5"))/E4

It works fine. In the above range i would get 1 like i want.
But it is not very dynamic. I want the "5" to be a cell and i would also like to use a formula like D4+1 in that position.

I hope some of you excel masters can help me.


could someone help me with this macro I can't figure out (more than new to VBA... )

I'm using the propername function on a range containing empty cells. It results in a range with my propernamed cells, and empty cells containing the function but not displaying anything. I want these empty cells to be deleted so that the text contained in the non-empty cells can expand over the empty cells (text longer than cells width, I must use this spacing)

This needs to be done for the range A8 to F500

Hope I'm clear... thanks in advance

I need to create a formula to average several cells, but the cells are not in a range.

So far I have =AVERAGE(G3, J3, M3, P3, S3), which works fine, but cells M3,
P3 and S3 are empty (zero) until I have the data that I need. I want the formula to already be set up for future input.

I've been able to make it work for a range of values (G3:S3), but not with indivual cells in a group.

Help please! Thanks.

Hi folks

I am importing data from the EPRIME (psych experimentation) software.
These files log reaction times and responses, etc. The problem is that
the clolumns contain some cells with no information and are blank, e.g.

Resp1.ACC ... repeated for 48 columns (variables)
0 ....etc, in 36 rows

How can I remove these empty cells, without having to do it manually?

Regards - MFG

MFGPosted from newsgroup access


I have the following problem.
My spreadsheet looks something like example # 1. The goal is to convert the data into something that looks like example #2. The spreadsheet of example #1 is about 27000 lines. The data of the column A in example #2 comes from a different spreadsheet that is about a 1000 lines long. I reckon that VLOOKUP would do the trick but I hope there is an easier way.

******** ******************** ************************************************************************> Microsoft Excel - Book40.xls ___Running: xl2000 : OS = Windows Windows 2000 (F)ile (E)dit (V)iew (I)nsert (O)ptions (T)ools (D)ata (W)indow (H)elp (A)bout A1 =
A B C D E F G H I J K 1 Example#1 empty empty empty Example#2 empty empty empty empty empty empty 2 1 a qwert empty empty a b c d e f 3 1 b asdf empty 1 qwert asdf zxcv empty empty empty 4 1 c zxcv empty 2 fghj empty tyre empty empty empty 5 2 a fghj empty 3 empty dfghj empty ddsew fgujyu pogmgf 6 2 c tyre empty empty empty empty empty empty empty empty 7 3 b dfghj empty empty empty empty empty empty empty empty 8 3 d ddsew empty empty empty empty empty empty empty empty 9 3 e fgujyu empty empty empty empty empty empty empty empty 10 3 f pogmgf empty empty empty empty empty empty empty empty Sheet1 *
[HtmlMaker 2.32] To see the formula in the cells just click on the cells hyperlink or click the Name box

I hope the above makes sense
Thanks very much for any help!


this is a sheet change event that does the following:
So as I type starting in A17
If value in column B is less than the value in column A then the difference is shown in column C
And it works perfect like this:

A17=5...B17=5...C17...s/b empty
A18=8...B18=8...C18...s/b empty
A19=3...B19=3...C19...s/b empty
A20=7...B20=6...C20...s/b 1

EXCEPT that in C17 I get 0 (zero) instead of an empty cell (all the rest of the "empty" are indeed empty without a zero)

Well that zero in C17 has to go for it interferes with my other code

Many thanks


'If Not Intersect(Target, Range("B17:B35")) Is Nothing Then
   ' x = Target.Row
    'Cells(x, 3) = Cells(x, 1) - Cells(x, 2)
'End If

P.S all cells in C17:C35 are formatted general

I have been trying to use LINEST for the analysis of a large sets of data but have just noticed that this function does not allow for empty cells in the data set. Apart from the tredious possibility of removing the blank cells (which is not really possible for the large quantity of data involved) does anybody have any suggestions?

I have tried using the following but have not had any success:


I do not want the formula to take the empty cells as being 0 but to exclude them from the calculation.

All help would be greatly appreciated.

I entered the following formula in a range of cells..=IF($S7=G$4,$N7,""). I then copied and pasted these cells as values. Now all of the cells where the result of the formula was "" actually contain an empty string (I believe this is what you would call it) and this empty string is causing other cells to the left where the contents is wider then the cell width to be cutoff. I hope this is clear. So, how can I get rid of this "empty string?" If I simply edit the cells (F2) then hit enter, the empty string goes away but I have hundreds of cells here to edit. Is there a better way?

Patrick Cox

I have a column with dates where are empty cells beetwen them:
like that:

28 Jan 10
28 Jan 10
28 Jan 10
02 Feb 10

whe using this formula
I'm getting 1 for every empty row.
How can I change that to count only cells where month is equal to 1(January).

This works except when it gets to cells (x, 7) and (x, 8) and both have a zero in the cell. I get an Error '6' "Overflow" message. How can I fix?

Dim x As Integer
Dim Y As Integer

x = 2
Y = 2

If Cells(x, 1) >= Not Empty Then
Cells(Y, 23) = Cells(x, 7) / Cells(x, 5)
Cells(Y, 24) = Cells(x, 7) / Cells(x, 8)
Cells(Y, 25) = Cells(x, 8) / Cells(x, 5)

Y = Y + 1

End If
x = x + 1
Loop Until Cells(x, 1) = Empty

Hi, ppl. I have an issue trying to exclude certain cells from being written to text file. Here is my code:

Please Login or Register  to view this content.

The result is this:

Please Login or Register  to view this content.

How can i get rid of the last rows being printed to the text file from empty cells BUT with a formula in them? I guess the macro interpret them as NOT empty when having a formula.


I'm working on a pricing analysis and basically I need to find the AVERAGE by excluding the smallest and highest numbers, MINIMUM without the smallest value, and MAXIMUM without the largest value.

So each formula should exclude only one value (MIN, MAX or both MIN and MAX with the average), so in cases where there are more values that are equal to the MIN or MAX, it should only exclude one of each, not all.

I tried using CSE formula but it keeps removing all values that are equal to MIN and MAX, and I only need one of them to be removed from the calculation.

For example, formulas I tried using:

{=MIN(IF(B6:L6<>MIN(B6:L6), B6:L6))}
{=AVERAGE(IF(B6:L6<>MIN(B6:L6), IF(B6:L6<>MAX(B6:L6), B6:L6)))}
{=MAX(IF(B6:L6<>MAX(B6:L6), B6:L6))}

Of course, empty fields should be ignored but I think blank cells are ignored in calculation anyways. Any ideas how I can go about solving this issue?

I know there is probably a simple solution but I am not an Excel wiz so I need your help.

Thank you.

hi, here i have attached sample sheet & pls check it. first sheet is my normal data & second sheet is my expected results. my request is column "K" has some empty cells. that empty cells i want to fill doing some calculation. as a my sample sheet K5 cell is 13.8 & k6 cell is empty. L5 cell is 7.5, so what want to do is that L5 cell value should copy to K5. now K5 cell is 7.5, then K5 before value is 13.8 need to (-) minus 7.5 & balance should add to empty K6.( should be 6.3).

as per my next example is K10 cell 712 & bellow 3 cells are empty. here also as K10,k11,k12 cell need to fill from L10,L11,L12 (k10=225,k11=225,k12=225) & last empty cell(k13) should be ,(K10 before value)712 -(225+225+225)=37.

I don't no this is possible or not. i need macro for this. pls help me. thanks in advance..

i've googled and searched for hours and still can't find a way to figure out how i can keep cells as empty ones. i just want the function to divide every input by 2, and if the input is an empty reference, keep the cell empty..sounds too simple but i can't do it! what's wrong with the code here!? thanks!

Function ppb(micrograms As Integer)
If micrograms = "" Then
ppb = ""
ppb = micrograms / 2
End If
End Function

I have 2 lists in which I need to find matching numbers then count the number of matches. The problem is these lists have empty cells for spacing purposes that span both columns and the formula is counting the empty cells as a "match".

My Formula would look like this


With the empty cells spanning across row 8 and row 23.

Any suggestions on how to ignore the empty spacer cells?

Hi all

I have lots of users who will fill in their weekly figures on a spreadsheet. When they close the file, I want to check that they have not left any cells empty. However, I cannot seem to get it to work.

If I use the range with only one cell, it works fine, but when I specify a whole range, it does not work.

Any ideas anyone?


Private Sub Workbook_BeforeClose(Cancel As Boolean)
If Worksheets("Data").Range("E5:AS5") = "" Then
    MsgBox "Please fill in all the empty cells before closing the file."
    Cancel = True
    Exit Sub
End If
Exit Sub


I want to write a script to make a sum of all the not empty cells within a column. Is there a trick so that Excel doesn't calculate all cells, only the not empty cells, so the calculation will be much faster?

thx in advance,

Hi all,

I've got a drop down pick box that I'm using.
Under format Controls, I have the following control settings:
Input range: $K$6:$K$16
Cell Link: H4
Drop down lines:10

Cells K6 and K16 are empty cells.

The formula Code:

=INDEX($K$5:$K$16, $H$4)

shows my selected cell value from the given range.

I would like to, be able to through code, set my selection to one of the empty cells.
I tried recording a macro to log the event but nothing was recorded.

Any help is appreciated.


Dear All,

I have a sheet that contains 2 colunms, A and B; they look like below:

A: B:
X 1
Y (empty)
Z (empty)

The last two cells in column B are empty, but this is subjected to change
I would like to paste the value of a cell (eg D3) to fill in the empty cells in column B with VBA (the last n cells are empty, there are no other empty cells)

Could you please help?
Many thanks

I have designed an Excel workbook which all calculates fine but because it has sumproduct formulas its slow for input.
I work in a business where 500 staff use one server, therefore it is quite busy (but it also happens at a quicker degree on my home computer).
When I input into workbook, on the bottom left of the screen it shows 'cells calculating %', then I cannot move to the next cell until calculation has finished, I understand this happening when the cells I input in are used for calculations but I don't understand why cells that are not used in any way for calculation still go through the 'cells calculating business'.
Is there any way I could make the workbook only calculate when for example saving/exiting etc


I am new here and just starting with excel. I have six empty cells, let say cells: A1,B1,C1,D1,E1 and F1. I need to make formula that calculates 1/A1+1/B1+1/C1+1/D1+1/E1+1/F1. Obviously it works fine when there are numbers in all cells but if only one cell is empty formula wont work. Could someone please assist. Tnx