Sum of combinations

P

p.stat

Hi,

I need help to approach a problem of this kind:
I have 4 products: A, B, C, D. I have to fix their prices.
Possible prices of product A: pa1, pa2, pa3, pa4.
Possible prices of product B: pb1, pb2, pb3.
Possible price of product C: pc1.
Possible prices of product D: pd1, pd2.

I want to get all possible revenues of sales of the products.

example
combin 1: pa1+pb1+pc1+pd1
combin 2: pa2+pb1+pc1+pd1
combin 3: pa3+pb1+pc1+pd1
combin 4: pa4+pb1+pc1+pd1
.....


thanks
p.
 
D

Dave O

Here are the combinations...
PA1 + PB1+ PC1 + PD1
PA1 + PB1+ PC1 + PD2
PA1 + PB2+ PC1 + PD1
PA1 + PB2+ PC1 + PD2
PA1 + PB3+ PC1 + PD1
PA1 + PB3+ PC1 + PD2
PA2 + PB1+ PC1 + PD1
PA2 + PB1+ PC1 + PD2
PA2 + PB2+ PC1 + PD1
PA2 + PB2+ PC1 + PD2
PA2 + PB3+ PC1 + PD1
PA2 + PB3+ PC1 + PD2
PA3 + PB1+ PC1 + PD1
PA3 + PB1+ PC1 + PD2
PA3 + PB2+ PC1 + PD1
PA3 + PB2+ PC1 + PD2
PA3 + PB3+ PC1 + PD1
PA3 + PB3+ PC1 + PD2
PA4 + PB1+ PC1 + PD1
PA4 + PB1+ PC1 + PD2
PA4 + PB2+ PC1 + PD1
PA4 + PB2+ PC1 + PD2
PA4 + PB3+ PC1 + PD1
PA4 + PB3+ PC1 + PD2

....and here is the code that generates them:
Sub Combinations()
Dim PA As Byte
Dim PB As Byte
Dim PD As Byte

For PA = 1 To 4
For PB = 1 To 3
For PD = 1 To 2
ActiveCell.Value = "PA" & PA & " + PB" & PB & "+ PC1 + PD" & PD
ActiveCell.Offset(1, 0).Select
Next PD
Next PB
Next PA

End Sub
 
P

p.stat

Dave O:
...and here is the code that generates them:
Sub Combinations()
Dim PA As Byte
Dim PB As Byte
Dim PD As Byte

For PA = 1 To 4
For PB = 1 To 3
For PD = 1 To 2
ActiveCell.Value = "PA" & PA & " + PB" & PB & "+ PC1 + PD" & PD
ActiveCell.Offset(1, 0).Select
Next PD
Next PB
Next PA

End Sub

Excellent!!
How could I generalize it?

Example:

In column B I have the names of the products, I don't know a priori how
many products are present in column B (between 2 and 100).
In cells to the right of the name of the product I have the values
(prices), I don't know a priori how many prices each product can assume
(between 1 and 6).
For example,
in cell B2 product1, in cell C2 90, in cell D2 100, in cell E2 150
in cell B3 product2, in cell C3 800, in cell D3 700
in cell B4 product3, in cell C4 5, in cell D4 8, in cell E4 3, in cell
F4 15
in cell B5 product4, in cell C5 130
....
In cells of column A I want to get all possible revenues of sales of
the products. Is it possibile?

Thanks
p.
 
P

Pete_UK

Surely, if these are prices, then revenues will depend on how many of
each product are sold - where is this information? Do you envisage
another range of up to 6 columns which would contain projected number
of sales? And does that mean you want the minimum and the maximum of
price times number, i.e. two columns showing the range of revenues for
each product?

Do you know how many possible combinations you could get from 100
products, each of which could have up to 6 values?

Pete
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

probs with devising quote system from master list of products 1
Excel formulation to automate values 3
VLOOKUP 2
V/HLookup 3
Excell Formula 2
excel newbie cell update 1
Minimum date per month 1
Excell Formula 2

Top