I'm average at Excel and this one has me stumped.
What im trying to do is calculate if a cell is 0 return a figure of 0, if the cell is greater than 0 but less than 61 (eg 60) return .15, if the cell is greater than 61 then divide the cell by 60 and round up to the next whole number eg if the cell is 86 the figure returned from the divide is 1.433 so i want that rounded to 2.
Any help would be great
Thanks
Here's your formula. Assumes your cell containing the value to be evaluated is A2
=IF(ISNUMBER(A2),IF(VALUE(A2)<=0,0,IF(VALUE(A2)<=61,0.15,ROUNDUP(VALUE(A2)/60,0)*0.15)),"0")
Here are the test results for all your conditions.
Maybe:
=IF(AND(ISNUMBER(A1),A1>0),IF(ROUNDUP(A1/60,)<2,0.15,0.15*ROUNDUP(A1/60,)),0)
Related
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)
what will be the formula to show results based on cell value. For example when i enter 30 in cell results will be 1, for 60 results will be 2 and so on. But if entered value will be less then multiple of 30 then result will show divisible of 30 for example if i enter 45 then result should be 1 and for less than 60 but greater than 30 then result should be 1.
use formula =INT(D2/30) where D2 is cell in which you have entered the value
I want to populate a cell according to the range of another cell. Like if the independent cell has the value between 12 to 16 then the dependent cell will be populated as -2 and if the independent cell has a value between 16 to 20 then -1 and if 20-24 then N and so on:
Sample
Is there any formula or how otherwise can I do it?
You could do it like this (place this formula in B1):
=IF(AND(A1>=12;A1<=15);"-2";IF(AND(A1>=16;A1<20);"-1";IF(AND(A1>=20;A1<25);"N";"N/A")))
Assuming 16 is "between" 16-20 rather than "between" 12-16 and that for N it is the text of the OP that counts rather than the image:
=LOOKUP(A1,{12,16,20,24},{-2,-1,"N"})
Negative values, zero, numbers less than 12 and positive or greater than 24, blanks and text would return #N/A.
LOOKUP.
Let's say I have the following table.
Team Score
AA 81
BB 67
CC 44
DD 1.5
JJ 279
LL 49
TT 201
GG 158
MM 32
HH 89
I want to get all teams that scored more than 80 in another table. I tried the Index + Match function as follows but it only gives me the smallest value greater than 80.
Here is the code:
=INDEX($A$2:$A$11,MATCH(80,$B$2:$B$11,-1))
Although I put the values in the lookup_array argument in descending order, this function only gives me one answer: The smallest value greater than 80.
I am trying to do this without having to sort the array and with a huge database mind you. Thank you.
Enter this formula to D2 and press CTRL+SHIFT+ENTER to make it an array formula, then drag it down.
=INDEX($A$1:$A$11,SMALL(IF($B$2:$B$11>=80,ROW($B$2:$B$11)),ROW(1:1)))
See How to look up a value in a list and return multiple corresponding values for details.
How about using an AutoFilter? You're then quite flexible in filtering for values in column score.
If you don't want to use vba, in a third column you could have
=if(B2 > 80, A2, "")
and copy that formula down. You could even put this column of formulas in another tab and either delete the rows that have nothing in them manually or write code that will do that for you.
Create a PivotTable (Team for ROWS, Score for Sigma VALUES, then filter the Sum of Score column for Number Filters, Greater Than..., and 80 next to Show rows where: is greater than *, OK.
* or perhaps is greater than or equal to.
Given a column of numeric values, is it possible to sum values until the total reaches a particular threshhold, then reset the sum total and continue? for example
Val Sum
103
52 155
47
60
103 210
100
76 176
163 163
169 169
87
103 190
84
31
59 174
87
49
67 203
This sums groups of numbers until the value exceeds 150, then resets the counter.
i'll post it more for the proof of concept than a real answer or for the case i could improve this (Issun may have an idea too).
Here it is:
Let assume your Val is in column A and Sum in column B and Titles are in row 1.
In column C, we will set a formula that will tell which is the "last" cell where you sumed it up > in cell C3, put:
{=MAX(IF($B$2:B2=0;0;ROW($B$2:B2)))}
This is an array formula, you will have to validate with CtrlShiftEnter.
In cell B3, you will have to put the first value (155 in your example), sorry, i didn't find a proper workaround.
In cell B4, put:
=IF(SUM($A$1:A4)-SUM(INDIRECT("$B$1:"&ADDRESS(C4;2)))>150;SUM($A$1:A4)-SUM(INDIRECT("$B$1:"&ADDRESS(C4;2)));0)
Then drag & drop the formulas till the end of your values.
[EDIT] Actually, you could put it all in a single formula in cell B2:
{=IF(SUM($A$1:A2)-SUM(INDIRECT("$B$1:"&ADDRESS(MAX(IF($B$1:B1=0;0;ROW($B$1:B1)));2)))>150;SUM($A$1:A2)-SUM(INDIRECT("$B$1:"&ADDRESS(MAX(IF($B$1:B1=0;0;ROW($B$1:B1)));2)));0)}
and drag and drop it till the end of your values. Seems to work too.
Simplest way to do it (no need for array formulas let alone VBA):
In B2, type =IF(B1<150,B1+A2,A2) and drag down. This will sum until it reaches 150 or more, and then restart at zero. Of course, the intermediate sums (i.e. on the way up to 150) will show as well. If this bothers you, a couple of options spring to mind:
Type =IF(B2>=150,B2,"") in C2 and drag down, and hide column B.
Apply conditional formatting to column B such that numbers below 150 get shown in white font.
Here's a solution in VBA (sorry I know you wanted a forumula). You can obviously tweat the range to be whatver you need it to be. Please note I used LONG as data type (and I am casting to long to avoid some errors), but you need to use DOUBLE if you have any floating point numbers.
Sub SumIt()
Dim cell As range
Dim currentCount As Long
For Each cell In range("A2:A100")
currentCount = currentCount + CLng(cell.Value)
If currentCount > 150 Then
cell.Offset(0, 1).Value = currentCount
currentCount = 0
End If
Next
End Sub
How it works: I loop through each cell in the range and add the value to a variable called currentCount. I then check if it's over 150, if it is I paste the currentCount to the B column (same row) and reset the count and move to the next cell. Simple!