IF statement with multiple worksheets in Excel - excel

I have a worksheet called Start at the beginning and a worksheet called End at the end of the sheets.
On my sheet in the middle, I want a cell to add up all of the I7 values from Start to End and if it is greater than 0 to display 0. If not, I want it to display the sum of all of the I7 values.
When I use this formula:
=IF(Start!I7:End!I7>0, 0, Start!I7:End!I7)
I get the error #value!
This formula works if I do =IF(Start!I7-End!I7>0, 0, Start!I7-End!I7) with the subtraction.

=IF(Start!I7+End!I7>0, 0, Start!I7+End!I7)
or are you asking to sum all pages between and including Start and End? You're subtraction equation only references those two pages...

You can use the sum function, but the syntax for summing the same cell across multiple sheets is a little different than what you have.
=IF(SUM(Start:End!I7) > 0, 0, SUM(Start:End!I7))
Refer to the sheet range, then the cell.
After your other question, I think the way to subtract all the subsequent I7 cells from the first one would be to just sum everything after it the same way we're doing here and subtract that from the initial value.
=IF(Start!I7 - SUM(Sheet2:End!I7) > 0, 0, Start!I7 - SUM(Sheet2:End!I7))
(I used Sheet2 as a placeholder. You would use the name of whatever sheet comes after Start.)
I think that it could be written more simply, though, using MIN.
=MIN(Start!I7 - SUM(Sheet2:End!I7), 0)

Related

Excel set 1 or 0 IF any value from array is between two values from treshold

There is a dynamic array in Excel with some values.
Values could change based on some formulas (doesn't matter which formulas).
There are tresholds (0-31, 61-85 and so on).
Based on these tresholds if any value from the first row of the array is between 0-31 then CM-11 should be 1, else 0.
For CM-12 we should take 31-61 and check if values 25,26,185,625 in this treshold or not. So in this case now it will be 0 since the criteria is false.
And so on for every cell.
Is there any sophisticated approach to solve and automate this task applying Excel formulas?
Or any other approach usingExcel?
Using this formula, as displayed in the further down image, you can count items in a range that are between thresholds:
=COUNTIFS($B$2:$D$4,"<"&F9,$B$2:$D$4,">"&E9)
Note the "<"& tied to a cell reference...
Checked for my small array if values were between 0 & 2, 2 & 4, 4 & 10, and 10 & 11.
Not a problem, I tried to put the images to help, you just need to adjust the correct cells
put a imput cell, a base value and a upper value to define the condition and put in the cell below
=uppercell + 30
Then use the following formula:
=if(and(base cell < input; imput < upper cell); 1; 0)

Syntax: Applying IF to a cell range in Excel

I've been trying to write a formula to summarise in one cell the presence/ absence of certain values in a different range of of cells in Excel
So in the one table and worksheet, I wrote
=IF(B1:F1=1,1,0) Formula 1
which is supposed to mean
If any of the values in cells B1:F1 are equal to 1, then note 1, otherwise not 0.
But somehow the syntax isn't working.
I've applied "" and ; and brackets right left and centre, but to no avail.
I'm pretty sure I done this before and it was pretty simple when I hit upon the right synstax, but the how and where fell through the colander which is my brain today :-?
Additionally I will want to ask the formula to apply another condition to the output cell which is
=if (A1 = value n or certain values, 1, 0) Formula2
Column A has numerically coded ordinal values 0-9, so an aexample of teh 1 conditions might be any of values 1, 2 or 9 in column, should produce a 1 in the result cell in which Formula 1 and 2 will be written.
So the result cell would contain somelike
=Formula1_or_Formula2_contain_certain_values, 1, 0) Formula 3
Obviously the systax of Formulas 2 and 3 is awol, but I write to demonostrate the formulae intended purposes.
The easiest way to make the first formula is like this:
=IF(SUM(B1:E1)>0,1,0)
No arrays, no problems :)

Counting from a specific range of data

Is there a formula without using VB to sum up a total number form a specific range of data?
For example:
Example
    
I need to sum up the number of times Mary took up the cooking lesson.
I understand that just by using the sum and manually select the range (B3:D3) I will be able to get it. But is there a formula to determine the range (B3:D3) instead?
Please advise. Thanks
The use of the merged cells in row 1 necessitates building a range with a pair of INDEX functions which is then re-examined with another INDEX to pick the row of data with a MATCH function. Once the range has been defined, a SUM function produces the result.
      
The formula in C10 is,
=SUM(INDEX(INDEX($B$3:$J$6, 0, MATCH($B10, B$1:J$1, 0)):INDEX($B$3:$J$6, 0, MATCH($B10, B$1:J$1, 0)+2), MATCH($A10, $A$3:$A$6, 0), 0))
Fill down as necessary.

Store an integer in a cell and use that to set the number of column gaps

I'm creating a revenue model on a simple spreadsheet. On the top, I have a variable cell (C5) that is the "number of weeks between transactions". Below that, I have a simple weekly revenue model.
Problem: What I would like is to be able to tweak the fields in yellow and have it apply dynamically to the model below so that it applies the sales amount from C4 every X weeks to the model below, where X is C5.
My initial guess was to use OFFSET, such as F10 =SUM(OFFSET(C10,0,$C$5)), but I've never used this function before and the more I think about it, I'm not sure if I'm approaching this correctly at all.
I created a mock desired results image to show what I would like to have happen if I enter 3 in C5 and then change it to 2.
May not be quite right but hopefully 'configurable' to suit. Assumes $500 is entered in C10 and (at least for the time being) 1 will not be entered in C5. Please try in D10 and copied across to suit:
=IF(MOD(COLUMN()-3,$C5)<MOD(COLUMN()-4,$C5),$C10,"")
A quick fix for the above failing to populate all cells when C5 is 1 is to wrap the formula in the condition =IF($C5=1,$C10,....)
MOD "returns the remainder after a number is divided by a divisor". The remainder being 0 when the number is an exact multiple of the divisor. If we take the first example (every third column) a suitable divisor is 3. Put =MOD(Column(),3) in A1 and copy across and the result is 1, 2, 0, 1, 2, 0, 1, ..... (Column() returns a number representing the column letter, with 1 for A, 2 for B etc., or the actual Column Heading where R1C1 reference style is checked under Working with formulas, in Formulas within Excel Options.)
So that establishes a series where every third position is identifiable as returning a value from MOD that is less than that of the immediately preceding cell. For the second example (every second column) with a divisor of 2 =MOD(Column(),2) in A1 copied across results in 1, 0, 1, 0, 1, ... so again the reduction in the remainder signals the position required for the formula to output the requisite value.
We are comparing the result of calculating the remainder for one column relative to the result of the same calculation performed on the previous column, hence -3, -4. Other (suitably paired) values might work equally well, it just seemed easier to 'start from zero' when in the first column for the formula (ColumnD or 4).
(If anybody would like to provide a proper explanation please feel free to edit!)

How to average every 7 cells without repeating the same cells

I have a long row of data that I am averaging week-by-week. I would like to grab the first 7 cells with data and be able to drag my formula over so that it grabs the next 7 days of data. Every time that I try this it always grabs the adjacent cell and averages numbers that I have already averaged in the previous formula:
So what happens is that when I drag to the right it grabs D60:K60 and I want it to grab L60:R60 instead.
How would I accomplish this?
This formula uses OFFSET to both stagger and shape the range which is calculated by AVERAGE.
=AVERAGE(OFFSET($C60, 0, (COLUMN(A:A)-1)*7, 1, 7))
Fill right as necessary. It will process AVERAGE(C60:I60) then AVERAGE(J60:P60), etc.
EDIT:
As OFFSET is a volatile function that re-calculates whenever any calculation cycle occurs within the workbook, here is a non-volatile equivalent.
=AVERAGE(INDEX(6:6, 1, (COLUMN(A:A)-1)*7+3):INDEX(6:6, 1, (COLUMN(A:A)-1)*7+9))

Resources