Get Sum of Products in same column - excel

I have the below data set:
Let's assume it starts in A1. I would like to calculate the Total Costfor January by taking each Count and multiplying by the Rate below it.
I currently have the following, nonsensical formula:
Total Cost = (B1 * B2) + (B3 * B4) + (B5 * B6) + ... + (Bn + Bn+1) for n > 0
Is there a whizzy way to do this using an Excel formula? Perhaps something with SUMPRODUCT()? But I can't seem to get that to work the way I need it...

Simplified example:
=SUMPRODUCT(--(A1:A5="Count"),B1:B5*B2:B6)

Related

Excel Formula/Function to Subtract randomly

I'm rather new to excel and I want to use excel or perhaps another program to subtract on a fixed amount but randomly.
It is like n1 + n2 + n3 = 300
But I want n1 and n2 and n3 to be different numbers hence not division
Examples
150 + 75 + 75 = 300
or
100 + 100 + 100 = 300
or
50 + 100 + 150 = 300
A function to subtract a fixed amount but random subtraction
I'm still quite confused on how to do this on excel, sorry for my bad English and explaination
Please help.
If it is always 3 numbers:
The first number we use:
=RANDBETWEEN(1,A1)
Then the second:
=RANDBETWEEN(1,A1-B1)
Then the third is just the remainder:
=A1-B1-C1
In excel you have your numbers in rows and columns
I would enter 100, 100 , 100 in separate columns of the same row and then use this
formula
=(A1+B1+C1).
Meaning row A1 100, row B1 100, row C1 100. The answer should be 300
if you want to subtract just use the minus sign instead of the plus sign:
formula =(A1-B1-C1).
Try:
=LET(A,RANDBETWEEN(0,300),B,RANDBETWEEN(0,300-A),HSTACK(A,B,300-SUM(A,B)))
Or, if no HSTACK() available:
=LET(A,RANDBETWEEN(0,300),B,RANDBETWEEN(0,300-A),CHOOSE({1,2,3},A,B,300-SUM(A,B)))
I'm just unsure if pure mathematically this is as random as can be. Would it be 'more random' if one would list all possible permutation of 1-300 that would add up to 300 and randomly pick a solution from this list?
One way to approach this if you want two numbers to always add up to the same value, is to modify each value with the same amount, by adding to one value and subtracting from the other
100 = n1 + n2 = (n1+a) + (n1-a)
where a is any random number.
To extend this to three numbers, you can use two artbitrary numbers a and b to do this following
100 = n1 + n2 + n3 = (n1+a) + (n2-a+b) + (n3-b)
The simplified approach to this it to pick completely random n2 and n3 and let n1 pick up the difference
100 = (100-n2-n3) + n2 + n3
To do this in Excel, use the =RANDBETWEEN() function for n2 and n3 and then for n1 just subtract from 100
=100 - SUM(n2,n3)

Excel formula for calculating product cost

I would like to calculate product cost based on the price and quantity in Excel
I have used the formula for
Product 1 - =(B2 * C2)/1000 + (B3 * C3)/1000 + (B4 * C4)/1000 + (B5 * C5)/1000
Product 2 - =(B2 * C2)/1000 + (B3 * C3)/1000 + (B4 * C4)/1000 + (B5 * C5)/1000
But the problem is if I add one more product, drag drop formula is not working.
Any better way to handle this?
Try to use a dynamic range in ready for the product additional rows
In C6, formula copied right to D6 :
=SUMPRODUCT($B$2:INDEX($B:$B,MATCH(9^9,$B:$B))*C$2:INDEX(C:C,MATCH(9^9,$B:$B)))/1000

Formula to Calculate Subscriber Churn Revenue

I'm trying to sum up 12 months of subscriber revenue factoring a 6% monthly churn (assuming no signups) to come up with the one-year value of a subscriber. A simple future value gives me the start and end values, but I'm looking to get the sum of the monthly declining revenues in a single Excel / Google Sheets formula. I can make 11 entries (plus the starting month full value), but is there a better one-liner or formula for this?
This gives me the 12th-month revenue:
=FV(-6%,11,0,100)
I'd like to get the sum without this:
=100 + FV(-6%,1,0,100) + FV(-6%,2,0,100) ... FV(-6%,11,0,100)
You are looking for the sum of a finite geometric series:
1 + r + r^2 + r^3 .... + r^11
And the sum of this series is
(1 - r^12) / (1 - r)
where r = 1 - 6%
So the formula would be
= (1 - (1-6%)^12 ) / (1 - (1-6%) ) * 100
This is assuming the OP meant
=100 + FV(-6%,1,0,-100) + FV(-6%,2,0,-100) ... FV(-6%,11,0,-100)
as FV(-6%,1,0,100) would output a negative number
I don't know much about such math but would the following formula give you the result?
=100+SUMPRODUCT(FV(-6%,ROW(1:11),0,-100))
The formula works in both Excel and Google Spreadsheets

getting wrong value when dealing with time in vba excel

I'm trying to do some calculations on my excel sheet where I'm using macros , i'm dealing with time values.
h2 = rg.Cells(i, 5) 'time value
h1 = rg.Cells(i, 4) 'time value
h3 = (TimeValue("23:59") - h1) + (h2 - TimeValue("23:59"))
the problem is for instance when h1="20:00" and h2="07:55" h3 should be 11:55 but it gives 12:05
BTW H1 is entrance time and H2 is time out so h2 is in the next day and i'm trying to calculate the deference of time.
regards
Because H2, as you point out, is a day after H1, you need to factor that in to your calculation.
So to calculate the difference between H1 and H2, 24 hours should be added to H2 first.
h2 + 1dy
07:55 + 24:00 = 31:55
v
-h1
31:55 - 20:00 = 11:55
A single day presented as time is 1 - as time is measured as a decimal fraction of a day.
So among many other ways of doing it, to get the above, your formula should be:
h3 = (h2 + 1) - h1
In fact the correct answer is minus 11:05:00 but Excel doesn't handle negative time. Adding one day to minus 11:05::00 equals positive 12:05:00.

using excel divide any value in a col by 1000, then multp new value by 10 & upd a running total cell, while leaving the orig value alone

For example if I enter a 2000 in B3, I would like that number divided by 1000, then multiplied by 10, and have the new value added to a running total. ie (2000/1000 * 10=20)
RunningTotal = 20
For clarity, if I enter 8000 in B4, then I would like to (8000/1000 * 10 = 80 )
RunningTotal = 100
Notice that
(x / 1000 * 10) + (y / 1000 * 10) = (x + y)/1000 * 10
So the equation for your running total cell only needs to be:
=SUM(B3:B10)/1000*10
Assuming B3:B10 is the appropriate range for your inputs.
equation formula
(x / 1000 * 10) + (y / 1000 * 10) = (x + y)/1000 * 10
=
(x+y) * 0.01
=
sum(B3:B?) * 0.01
You can simply record a macro:
http://office.microsoft.com/en-us/excel-help/create-a-macro-HP005204711.aspx
So you do everything you would like to calculate "by hand" while recording a macro and then you can call it at any time you want to execute.
Thanks for the replies.
I will be entering in values into col B(B3,B4...B200 etc.). The running total value will be displayed in it's own cell. The running total value will be updated upon save or enter. The orig value entered into the B column cells should remain the same.
The formula or calculation should occur anytime a value is entered into a cell within col B.
So if I have any number of values in col B, what I am expecting is:
1000/1000 * 10 = 10
5000/1000 * 10 = 60
8000/1000 * 10 = 140 etc.
If I use a separate cell to hold the runningTotal value, for ex K2...formula is: =C3/1000*10 ...how can I repeat this formula for subsequent cells in col B, but update the cell K2?
Must I use a holding column for each corresponding value entered in col B, then add the value to the K2 cell?
Ah, yes, I have managed to get it working by using a holding cell. if there is a more elegant approach, I am open to suggestions.
thanks for your advice.

Resources