Combining functions in Excel? - excel

Please see my image,
I am need to count number of rows that have the cell value (in G column) = 1; but the values of column A and column B not equal another rows (not loop). For example: Row 4 have A4 = A3 = 16 and B4= B3 = 221 so we ignore (Row 6 is ignore, too).
Do you know what is the proper function ?
Thank you very much.

As per your image, use this one in I1 and drag it down:
=IF(AND(G1=1,COUNTIFS($A$1:$A1,$A1,$B$1:$B1,$B1)=1),"YES","NO")
and then in I8 you can use
=COUNTIF(I1:I6,"YES")

You can just do something like this, where you can add as many other conditionals as you need to the AND function.
=IF(AND(G4=1, NOT(A4=A3), NOT(B4=B3)),"True","False")

I'm having a little trouble following the logic in your question - the best solution is likely to write a custom VBA function and then call that function per cell. See www.cpearson.com/excel/writingfunctionsinvba.aspx

Related

How can I set the value of a cell based on the larger of two sums?

As the subject says, I need to set the value of a cell to the larger of two sums. It seems basic enough but so far I can't get it working.
For instance:
=SUM(B9 + B12) 178
=SUM(B10 + B11) 12
Is there a way to compare two sums and to conditionally set another cell's value?
=MAX(SUM(B9,B12),SUM(B10,B11))
If your SUM functions are already located in cells somewhere on your sheet, say maybe A1 = SUM(B9,B12) and A2 = SUM(B10,B11), then you can just use
=MAX(A1,A2)
That what the MAX function is for. You don't necessarily need the SUM functions in this particular case (though it doesn't hurt).
=MAX(B9+B12, B10+B11)
If your SUM formulas are already in their own cells, just use the MAX function on those cells.

Additional formula needed in IF statement

I currently have a large nested IF statement that uses a helper cell (C1) to dictate which formula to utilize based on numbers 1,2,3,5 & 6. Specifically, one IF statement within the larger nested IF statement needs to be updated for instances when there is a blank cell in column A. Here is how my workbook is setup:
Data Tab
Bonus Tab
Summary Tab
This is my current formula in Column B:
=IF(Data!$C$1=2,IF(SUM(Bonus!B2:C2)<1,0,1)*Data!$B$3+Data!$B$2)
What I am looking for is when cells in column A are blank, than the corresponding cell in Column B would be 0. Again, the formula above has to remain in the =IF(Data!$C$1=2, format since it is part of a larger nested IF statement.
Answer I am seeking:
Thank you for looking!
Try this:
=IF(Summary!A2="",0,IF(Data!$C$1=2,IF(SUM(Bonus!B2:C2)<1,0,1)*Data!$B$3+Data!$B$2))
How about adding an IF in there like this?
=IF(Data!$C$1=2,
IF(LEN(Summary!A2)>0,1,0)*
(IF(SUM(Bonus!B2:C2)<1,0,1)*Data!$B$3 + Data!$B$2))
or like this
=IF(Data!$C$1=2,
IF(LEN(Summary!A2)>0,
IF(SUM(Bonus!B2:C2)<1,0,1)*Data!$B$3 + Data!$B$,
0))
What about:
=IF(AND($C$1=2,LEN(A2)>0),IF(SUM(Bonus!B2:C2)<1,0,1)*Data!$B$3+Data!$B$2)
I realise this gives you FALSE rather than 0 at the end, but I don't know what the rest of your 7 IF statements look like.
EDIT
Based on #AlexisOlson 's comment:
=1*IF(AND($C$1=2,LEN(A2)>0),IF(SUM(Bonus!B2:C2)<1,0,1)*Data!$B$3+Data!$B$2)
This now returns 0 when Column A is blank, as required.

Determine what section a value falls between given a range of values

I am trying to write a function in Excel that will return what the Section Number for a given value would be. For instance the 1200 value would fall in Section Number 1, and so on. I am trying to stay away from writing a VBA function to do this.
So what would be a good way to do this?
You can use VLOOKUP like this:
=VLOOKUP(I2,$E$2:$G$11,3,TRUE)
Assuming your data is in Column E to G and you want Section number in column J. Place the formula in cell J2 and drag it down.

EXCEL How do I ignore a cell if a cell has a value

I have a row that will have weekly values entered. Column B has the initial value, and E has the calculation; as I add values to C, D and so on, I want the calculation to skip the previous columns value when the next column gets a value.
B1-C1=E1 BUT when a value is added to D1, E1 would update to B1-D1=E1
Sorry for the horrible description. This is probably answered somewhere on this site but I am not sure what terms to search.
Many thanks!
you can use an if statement. I am not 100% sure of your problem but something like this might be helpful.
if(A1, A1, 0)
So for your example provided.
=B1-if(D1, D1, C1)
This says if there is a value in D1 use D1 else use C1. This works in this example, because if
D1 is empty or 0 you will use the other cell. This may change for any given problem.
Use this if function in E1:
=IF(D1>0,B1-D1,IF(C1>0,B1-C1,B1))
Then enter a value in B1, then C1 then D1 to see the results.
According to your question, you only have room for two entries after the default B1 value. This statement will handle that.
If you need more fields, nest more if functions. But if's can only be nested 7 deep, so you can only have an initial value in B1 and 7 more cells, C1 to I1 with your formula in J1
If you actual data is as simple as your sample data you could just use:
=IF(LEN(D2)>0, B2-D2,B2-C2)
You could also use:
=IF(ISBLANK(D2), B2-C2, B2-D2)
if you prefer but Len is a little shorter and I believe the ISBLANK() function has flaws, If you have a formula in D2 that has a calculation and you set the result to "" then it will pick up as false. It depends on your needs.
I would do the following.
In E1 paste the following:
=A1-INDEX(B1:D1,1,COUNT(B1:D1))
The count formula will tell how many values are present in the range of B:D column. This will be used to catch the last column with an index formula which will be deducted form A1.
One thing is very important! The values from A to D has to be written in sequence, if one column is missing than the calculation will be false.
Hope I could help!

Creating Excel Function: Average of Dynamic Range

I have a list of 4000 different price values in one column. I want to calculate the average of the first X values in the column and display the result in cell "B21". The value of X can be changed and is located in cell "B20". How would I use excel functions to do this? Perhaps Average and Offset?
This will do it:
=AVERAGE(A1:INDEX(A:A,B20))
Note that a 0 or blank in B20 will average the whole column. You could filter that out with an IF statement:
=IF(B20=0,"NA",AVERAGE(A1:INDEX(A:A,B20)))
As Barry mentioned in his comment, I chose INDEX because it's not as volatile as OFFSET and INDIRECT.
How about:
=AVERAGE(INDIRECT("A1:A" & B20))
I'll throw my hat in the ring as well using the functions the op suggested.
=average(offset(A1,0,0,B20))
As Doug's comment this will also give an error with blanks or 0 in B20.
Gordon

Resources