How can I multiply only the cells that contain value? - excel-2010

I have a Excel spreadsheet with 40 columns but the number of lines for each column varies. I need to multiply these cells by a value. How can I multiply only the cells that contain a value?
Thanks

Depends a bit on what you want the result to be if the cell is blank.
If you have a a formula such as "=A1*B1*C1" but A1 could be blank, and you want just the product of B1 and C1 in that case, then you could amend the formula to something like:
=IF(ISBLANK(A1), 1, A1)*B1*C1
Otherwise it will treat it as zero and the overall product will always be zero.

You could something like:
=IF(C5="",1,C5) * IF(D5="",1,D5) * IF(E5="",1,E5)

=IF(C5="",1,C5) * IF(D5="",1,D5) * IF(E5="",1,E5)*IF(C5&D5&E5="",0,1)
This is the best formula.
If all of your cells was empty this formula didn't show “1” as the answer. And it will show you zero.

Related

GOOGLE SHEETS: Help needed to sum a range of cells across rows, where the range is controlled by a variable

I need to sum a range of cells across rows, but I need to be able to specify the amount with a variable.
For example.
If i write 5 in cell B1, I want to sum range A1:A5.
If i write 10 in cell B1, I want to sum range A1:A10.
If i write 20 in cell B1, I want to sum range A1:A20.
And so on.
Does anyone know a formula for this?
Kind regards.
I tried writing( in cell B1) =SUM(A1:A(1+B1)). This didn't work at all, instead a =NAME? appeared.
You may use INDIRECT to set a range by joining text, like this:
=SUM(INDIRECT("A1:A"&B1))
This formula will also work:
=SUM(BYROW(SEQUENCE(B1),LAMBDA(ROW,INDEX(A1:A,ROW))))
SEQUENCE() return an array of rows count up from 1 by default.
BYROW() can use an array as row reference and apply a LAMBDA() function to each row.
INDEX() return the CELL the matches a given INDEX of ROW and COL.
SUM sum up every value of a range (array).
also possibility:
=SUM(A1:INDEX(A:A; B1))
or:
=SUMPRODUCT(A1:INDEX(A:A; B1))

Sum two ranges separately in one formula

How can I do one single formula to sum two ranges and display them in their respective column.
Here I'm using SUM formula in each cell but I'm sure there must be a single formula that can accomplish this.
Value 1 and Value 2 are the ranges to add them together in Sum row.
Here is an example picture.
Since arrayformula does not support sum, I suppose you could also do this in C12:
=arrayformula(C10:I10+C11:I11)
Clear the formula you have in row 12 and then enter in C12
=index(mmult({1,1}, --C10:I11))
Change range to suit and see if that helps?

Google sheets subtract cells N columns and rows apart

how can I subtract cells A2 from A1 without directly using cell addresses? I would like to write A2 as a cell -1 column away and A1 as a cell -1 column away and -1 row away.
image
Thanks in advance <3
You can make use of the offset function on sheets.
An example formula based on your example would be: =(OFFSET(B2,0,-1)-OFFSET(B2,-1,-1))
You can use the INDIRECT function along with ADDRESS, ROW and COLUMN
=INDIRECT(ADDRESS(ROW(),COLUMN()-1))-INDIRECT(ADDRESS(ROW()-1,COLUMN()-1))
You can also use Indirect with RC notation as below:
=indirect("RC[-1]",false)-indirect("R[-1]C[-1]",false)

Formula for finding the value in a range of cells that is closest to zero, where those cells include letters

I want cell A4 to show the number in cells A1:A3 that is closest to zero, including if that number is negative, and where some of those cells may contain "na".
I've tried MIN with ABS but that can't handle the "na".
many thanks in advance.
B
=ArrayFormula(min(iferror(abs(A1:A3))))
If you wanted to find the original value with its sign (+/-), would need something like
=ArrayFormula(index(A1:A3,match(min(iferror(abs(A1:A3))),iferror(abs(A1:A3)),0)))
Please try:
=min(ArrayFormula(if(isnumber(A1:A3),abs(A1:A3))))

Formula to find last value in row and label with Column Top

I'm using Google Spreadsheets. I'll be using this image from a very similar question.
http://i.imgur.com/jqcNW.png [a link]Google Spreadsheet Formula to get last value in a row
Instead of giving the value, I want the Column top to show. So the H column would look something like: 2 1 3 1 4
(The product numbers from Row 1)
If it helps =index(B2:G2;1;counta(B2:G2)) was the answer given to the original question. My values would be words instead of numbers. It'd need to track the last 'Yes' in the row with the column top being dates.
I think this should be easy:
=index($B$1:$G$1;1;counta(B2:G2)) - if you write this to the H2 cell, it should search the "N"th element in the FIRST row ($B$1:$G$1) - where N represents the value of non-empty cells in that row (B2:G2).
You can then populate this H2 formula downwards.
Let me know if this helps.

Resources