Excel Formula If then - excel-formula

I am new to excel and looking to see how to do this formula correctly. On A1 I have the data texts Promoters, Passives and Detractors. I am not sure why my formula is not working.
What I wanted to happen, is make a formula where in if on cell B1 Promoters, then RANDBETWEEN 9 or 10, If Passive then Rand Between 7 and 8 and If Detractors, then RANDBETWEEN 0 to 6.

So, perhaps you want:
IF(A1="PROMOTERS",RANDBETWEEN(9,10),IF(A1="PASSIVE",RANDBETWEEN(7,8),IF(A1="DETRACTORS",RANDBETWEEN(0,6),"Error")))
If I followed correctly.

Related

Input data into a 2nd cell, based on the value of a 3rd cell? (Like "conditional formatting")

B1 is a checkbox. If checked B1=1. A1 can range from 0 to 10. If B1 is checked I want A1 to automatically = 10. Exactly like conditional formatting would turn it green. I cant put the formula =IF(B1=1,10,"") into A1 though because I need to be able to input other values in A1 without erasing the formula. I need to be able to reuse the sheet multiple times.
Ex.
A B
1 10 x
2 9
3 10 x
4 4
As Scott commented, you'd need to use VBA to do exactly what you're asking. A work-around, though, would be to add a third column with:
=IF(B1="x",10,A1)
In this case, Column A would be the user-inputted number, Column B would be your "x", and Column C would give the final output: 10 if B has "x", and the number from A otherwise.

COUNTIF to calculate number of occurances between 2 values

I have no idea what is wrong with my formula and I would like to learn from my mistakes:
I have a range of values, say A1:A100, and I want to count the number of times a value from 0 to 10 appears, 10 - 20 appears etc. and put it into a frequency table.
I am put value 0 and 10 in cells B1 and C1 respectively, 10 and 20 in B2 and C2 respectively etc. (i.e. the frequency table is from columns B to D)
In D1, my formula is:
=COUNTIF($A$1:$A$100,AND(">="&B1,"<="&C1)
However, this formula doesn't seem to work and always returns 0. It would be greatly appreciated if anyone can enlighten me on why my formula doesn't work. Thanks in advance!
Use COUNTIFS for multiple conditions.
=COUNTIFS($A$1:$A$100, ">="&B1, $A$1:$A$100, "<="&C1)

Conditional formatting Excel results from cell, address functions

I am using the cell, address, index, and match functions in Excel to return the address of the intersection of a row and column match. I can get the address correct using the following function, but I can't get it to format using conditional formatting with a formula.
=a2=CELL("address",INDEX(A2:E6,MATCH("g",A2:A6,0),MATCH("c",A2:E2,0)))
The data looks like this and the upper left corner is in cell A2.
a b c d
e 1 2 3 4
f 5 6 7 8
g 9 10 11 12
h 13 14 15 16
I want to enter a formula that colors the matching cell a certain color (the "11", in this example). How do I get this to work? If I just type =a2=$D$5 in the conditional formatting formula, it works, but I can't get it to work using the formula above.
Try following. I tested and got correct formatting.
=CELL("address",A2)=CELL("address",INDEX($A$2:$E$6,MATCH("g",$A$2:$A$6,0),MATCH("c",$A$2:$E$2,0)))
This will also work if there is no duplicate values in range.
=A2=INDIRECT(CELL("address",INDEX($A$2:$E$6,MATCH("g",$A$2:$A$6,0),MATCH("c",$A$2:$E$2,0))))
Another way to do that
=CELL("address",A2)=ADDRESS(MATCH("g",$A$1:$A$6,0),MATCH("c",$A$2:$E$2,0))

I am trying to find a formula that will allow me to calculate MAX/MIN without calculating anything after the current row

I want to use the Max/Min function to calculate the minimum number up to the current row, but not count anything after that row. See example below:
A B C
1 10 =MIN(A1:A1) I Want B1 to only count MIN from A1 to A1 from here, then
2 14 =MIN(A1:A2) from here I want B2 to count MIN from A1 to A2,
3 9 =MIN(A1:A3) Then A1 to A3,
4 6 =MIN(A1:A4) etc,
5 14 =MIN(A1:A5) etc.
I could go back and update each row manually, but I have over 700 rows that I want all this to apply to. Is there anyone who can help me with a solution to this problem?
Use this formula in B1, and copy downwards:
=MIN($A$1:$A1)
This is called maintaining referential integrity while writing any excel formula. It should give the desired result on copy towards right or downwards.

Excel countif(s) multiples

I'm trying to calculate the count of multiple occurrences of a figure using countif.
I have the range set but I need a calculation which can count in multiples of 50 without me having to type thousands of versions of countif (=COUNTIF(B2:B5,">=50")-COUNTIF(B2:B5,">100" etc.).
Data Count
50 1
70 1
80 1
10 0
150 3
This data should show 6 but at the moment I'm getting 4.
First you can start by making bins. you can make it with Data analysis tool or half manual
Like in the example, on A2 enter 0 and on b2 enter =a2+50
Same goes for a3 enter =b2 and last on a4 =a3+50
Now you can drag it down as much as you like.
Instaed of using countif use sumif finction. let's assume your data is on cloumn H and the values you want to sum are in column I, then on c2 enter
=SUMIFS(I:I,H:H,">"&A2,H:H,"<="&B2)
you can drag it down as much as you like.
Simply use Excels ROUNDDOWN function:
e.g. for B2: =ROUNDDOWN(A2/50,0)

Resources