Excel formula for calculating product cost - excel

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

Related

Search and replace partial string in vb.net code

I have the following code as an example:
A = 1 - A1 + 40
B = 1 - B2 + 40
C = 1 - C3 + 40
How can I use REPLACE in Visual Studio so that it misses A1, B2 and C3 and substitutes the rest with a different code, so it looks like the following code for example?:
A = 2 * A1 + 5
B = 2 * B2 + 5
C = 2 * C3 + 5
It's a simple example, but I've found myself in situationes where I would just like VS to only REPLACE a certain part of the code and miss other parts. I was trying to look for something like this:
SUBSTITUTE 1 - ** + 40 WITH 2 * ** + 40, if you get what I mean.
A regex replace would be probably the easiest and most flexible way to solve this, i.e. using the alternate | operator to define alternative characters to replace with Z1: Demo
(?:A|B|C)5
You could also alternate between specific cell coordinates in the same way, e.g.
(?:A5|B6|C7)

Get Sum of Products in same column

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)

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

Counting cells that have data in given month

I have a database that collects employee training dates and offer dates and I want to see how many employees have been trained in a given month.
My below formula checks B2's date and then counts offers in that month that have completed training, but I must be going wrong as it appears to be multiplying the figure.
=SUMPRODUCT((COUNTIF(Database[Training Date],"*"))*(MONTH(Database[Offered Date])=MONTH(B2))*(YEAR(Database[Offered Date])=YEAR(B2)))
All I want it to do is count if the employee has a training date and ignore the blank cells in a given month.
Database Table:
************************************************
* Employee * Training Date * Offered Date *
************************************************
* John * YES * 21/02/2016 *
* Joe * YES * 18/02/2016 *
* Suzy * * 16/02/2016 *
************************************************
If you have xl2007 or newer, try the COUNTIFS function.
=COUNTIFS(database[training date], "yes", database[offered date], ">"&EOMONTH(B2, -1), database[offered date], "<="&EOMONTH(B2, 0))
The COUNIFS function is vastly superior to the the older SUMPRODUCT function in terms of calculation load; typically 25-35%.
Your own formula could have discarded the COUNTIF function and just replied on the SUMPRODUCT.
=SUMPRODUCT((database[training date]="yes")*(MONTH(database[offered date])=MONTH(B2))*(YEAR(database[offered date])=YEAR(B2)))

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