Click here to Skip to main content
15,884,388 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In the Excel Sheet I'm using If function but not working properly, What I'm trying is in my sheet there are three columns heading as Column A, Column B and Column C in Column A Cell A1 to Cell A10 are filled and in Cell B1 user will provide some number which will be carried out by other cells from B2 to B10 using =$B$1 formula now what I want is that in Cell B2 I want to put this formula =If(A1="",0,B2=$B$1), means if cell A1 is blank then cell B2 will return 0 and if cell A1 contains data then it it will fetch the value of Cell B1, But this formula only returns 0 and not fetching the value of cell B1. Please someone help to solve it. If there is any wrong in the formula so please guide me proper function to solve.

What I have tried:

what I want is that in Cell B2 I want to put this formula =If(A1="",0,B2=$B$1), means if cell A1 is blank then cell B2 will return 0 and if cell A1 contains data then it it will fetch the value of Cell B1
Posted
Updated 29-Dec-21 10:14am

Take out the comparison:
=IF(A1="",0,$B$1)

With your version:
=IF(A1="",0,B2=$B$1)
It's trying to fetch the current value of cell B2 and compare it with $B$1 in order to modify cell B2 - with is a circular reference because the assignment to B2 would change the value in teh comparison, which would change the assignment, which ...

And BTW: I know you are a Help Vampire (your record of Q vs A shows that) but this isn't an Excel help forum: in future these queries should be directed to a site that is.
 
Share this answer
 
Comments
Maciej Los 29-Dec-21 14:44pm    
5ed!
Quote:
Please someone help to solve it. If there is any wrong in the formula so please guide me proper function to solve.

Learn to use Excel integrated helping tools.
Ribbon 'Formula' > 'Formula Audit' Block > 'Formula Evaluate' : this tool will show you how Excel avalate the formula step by step, it helps you to understand where the formula goes wrong. Great learning tool.
Quote:
=If(A1="",0,B2=$B$1)

As far as I understand your problem, you should try:
VB
=If(A1="",0,$B$1)

[Update]
Have a look at this tool: FormulaDesk - FormulaSpy[^]
 
Share this answer
 
v2
Comments
Maciej Los 29-Dec-21 14:44pm    
5ed!
Patrice T 29-Dec-21 18:08pm    
Thank you.
In a short, this part of your formula: B2=$B$1 evaluates into boolean value and returns:
- true - if B2=$B$1
- false - if B2<>$B$1

So, the result of formula: =If(A1="",0,B2=$B$1) should be true/false if A1 cell contains data... :)

Got it?
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900