Blank cells being read as 0

Shodi

Board Regular
Joined
May 24, 2016
Messages
53
Hello everyone, I need help with a template I have created.
The template in of 2 sheets where Sheet 2 reflects data manually inserted in Sheet 1.

Eg: Cell A1 in Sheet 2 has the formula =IF('Sheet1'!A1="","",'Sheet1'!A1),
Cell B1 in Sheet 2 has the formula =IF('Sheet1'!B1="","",'Sheet1'!B1) and so on.

Now the data from Sheet 1 fills 145 rows till column AB in Sheet 2.
In column AC in Sheet 2, I have a SUMIF formula that calculates the values row wise in Sheet 2 itself.
The issue I face is that the SUMIF formula in AC is reading the blank cells in Sheet 2 as 0 and hence the output is inaccurate.
Currently I am having to copy paste as values (removing the formulas) the data in Sheet 2 and then insert the SUMIF formula in column AC. This actually beats the purpose of a template with linked sheets.
Please help me with a way around this. Thanks in advance.
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying

BarryL

Well-known Member
Joined
Jan 20, 2014
Messages
1,436
Office Version
  1. 2019
Platform
  1. Windows
  2. MacOS
If its adding 0 how does that effect a SUMIF?
 
Upvote 0

Shodi

Board Regular
Joined
May 24, 2016
Messages
53
Dear Barry, the SUMIF formula is calculating the sum of constants in row A1 to AB1 based on the values in the rows below

EG:
in cell AC2 the formula I have is =SUMIF(A2:AB2,"<>",$A$1:$AB$1)
in cell AC3 the formula I have is =SUMIF(A3:AB3,"<>",$A$1:$AB$1) and so on.

When this formula reads a blank cell as 0 the resulting output includes the values in A1 to AB1 that should not be considered as the corresponding value below is blank.
To make this clear please find a sample data below.

ABCDEFGH
Row 1Constant22243518
Row 2DATA 12233018
Row 3DATA 212223118
Row 4DATA 321318
Row 5DATA 42124518
Row 6DATA 52123518

<colgroup><col width="64" span="9" style="width:48pt"> </colgroup><tbody>
</tbody>

This is how the SUMIF formula is behaving now because it has read the presence of the formulae in cells C2, B4, E4, G4, F5 and D6 as 0 and is returning the sum of all the values from B1 to G1.
Ideally the results appearing in column H is, H2=16 (C2 is blank hence 18-2), H3=18 (NO BLANK CELLS), H4=7 (B3, E3 and G3 are blank hence 18-11) and so on. Hope this is clear. Please help.
 
Upvote 0

BarryL

Well-known Member
Joined
Jan 20, 2014
Messages
1,436
Office Version
  1. 2019
Platform
  1. Windows
  2. MacOS
do you mean?

=SUMIF(A3:AB3,"<>""",$A$1:$AB$1)
or
=SUMIF(A3:AB3,"<>"&"",$A$1:$AB$1)
 
Upvote 0

Special-K99

Well-known Member
Joined
Nov 7, 2006
Messages
8,426
Office Version
  1. 2019
What does this result in?

=LEN(C2)
=CODE(C2)

Is this website related in which case the blanks could be CHAR(160)
 
Upvote 0

Shodi

Board Regular
Joined
May 24, 2016
Messages
53
This is not website related, it is purely data in excel.

The formula I am using currently is =SUMIF(A3:AB3,"<>",$A$1:$AB$1).

This is meant to return the sum of values from A1 to AB1 where the corresponding cells in the rows below have numeric values meaning if a cell in a row is blank then the result will not include the corresponding value in A1:AB1 in the summed output.
 
Upvote 0

Special-K99

Well-known Member
Joined
Nov 7, 2006
Messages
8,426
Office Version
  1. 2019
I didnt think you could put a range of test values in a SUMIF.
If that is the case then you'll have to use SUMPRODUCT.
or perhaps SUM(IF(...))

For clarity still no answer on
=LEN(C2)
=CODE(C2)

???
 
Last edited:
Upvote 0

Shodi

Board Regular
Joined
May 24, 2016
Messages
53
The SUMIF formula is giving be the desired result. The only glitch is the bank cells being read a 0.

C2 has the formula
=IF('Sheet1'!C2="","",'Sheet1'!C2),

=LEN(C2) gives "0".

=CODE(C2) gives "#VALUE".

Is there a way around this? Please!!
 
Upvote 0

FormR

MrExcel MVP
Joined
Aug 18, 2011
Messages
6,905
Office Version
  1. 365
Platform
  1. Windows
in cell AC2 the formula I have is =SUMIF(A2:AB2,"<>",$A$1:$AB$1)

Hi, here is an alternative formula that you can try:

=SUMPRODUCT(--(LEN(A2:AB2)>0),$A$1:$AB$1)
 
Upvote 0

Shodi

Board Regular
Joined
May 24, 2016
Messages
53
Dear MrExcel, thanks a lot, this SUMPRODUCT formula is not reading the blank cells even though the cells have a formula in them.

Would you also please be kind enough to explain this formula as I am not able to understand how this works??
 
Upvote 0

Forum statistics

Threads
1,190,898
Messages
5,983,467
Members
439,843
Latest member
PlanetFitness

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top