Saving reference down a column as its reference is changed

%3CLINGO-SUB%20id%3D%22lingo-sub-1517298%22%20slang%3D%22en-US%22%3ESaving%20reference%20down%20a%20column%20as%20its%20reference%20is%20changed%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1517298%22%20slang%3D%22en-US%22%3E%3CP%3EHello%2C%3C%2FP%3E%3CP%3EI%20would%20like%20to%20calculate%20total%20sales%20amounts%20by%20simply%20typing%20the%20number%20of%20sales%2C%20and%20using%20a%20selector%20box%20to%20determine%20the%20product%20being%20sold%2C%20and%20thus%20the%20amount%20made%20on%20the%20sale.%3C%2FP%3E%3CP%3EMy%20problem%20is%20that%20when%20i%20change%20the%20product%20being%20sold%2C%20it%20changes%20the%20amount%20of%20past%20sales%20as%20well.%3C%2FP%3E%3CP%3EI've%20included%20a%20small%20file%20as%20an%20example.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI'd%20like%20to%20enter%20a%20new%20number%20to%20cells%20D6%3AD10%20as%20sales%20are%20made%2C%20and%20select%20the%20product%20being%20sold%20at%20the%20time%20through%20the%20drop%20down%20list%20in%20E1.%3C%2FP%3E%3CP%3EThen%20I'd%20like%20the%20price%20of%20the%20product%20to%20be%20automatically%20entered%20in%20column%20E6%3AE10%2C%20and%20remain%20even%20after%20selecting%20a%20new%20product%20in%20the%20drop%20down%20box.%3C%2FP%3E%3CP%3EAny%20code%20or%20design%20suggestions%20are%20greatly%20appreciated.%3C%2FP%3E%3CP%3EKyle%20Parenzan%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1517298%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EFormulas%20and%20Functions%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1517354%22%20slang%3D%22en-US%22%3ERe%3A%20Saving%20reference%20down%20a%20column%20as%20its%20reference%20is%20changed%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1517354%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F706232%22%20target%3D%22_blank%22%3E%40Kyle_P19%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESee%20the%20attached%20for%20one%20solution.%3C%2FP%3E%3CP%3EYou%20just%20needed%20to%20make%20the%20drop%20down%20part%20of%20the%20row%20in%20which%20the%20calc%20took%20place.%26nbsp%3B%20And%20assuming%20your%20real%20world%20application%20has%20more%20than%20two%20products%2C%20use%20VLOOKUP%20rather%20than%20your%20IF%20formulation%20to%20determine%20the%20per%20unit%20price.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1517360%22%20slang%3D%22fr-FR%22%3ERE%3A%20Saving%20reference%20down%20a%20column%20as%20its%20reference%20is%20changed%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1517360%22%20slang%3D%22fr-FR%22%3Ebonjour%2C%20quand%20je%20voulais%20imprimer%20et%20convertir%20en%20pdf%2C%20je%20ne%20vois%20pas%20la%20page%20entier%2C%20sur%20exel%2C%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1517385%22%20slang%3D%22en-US%22%3ERe%3A%20Saving%20reference%20down%20a%20column%20as%20its%20reference%20is%20changed%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1517385%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F425987%22%20target%3D%22_blank%22%3E%40mathetes%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThis%20is%20the%20right%20solution%20to%20calculate%20line-item%20totals%20providing%20the%20intention%20of%20Number%20of%20Sales%20is%20%22units%20sold%22%20and%20not%20%22line%20item%20%2F%20row%20number%22%20(it's%20not%20clear%20to%20me%20which%20is%20intended%20tbh).%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAdditionally%2C%20I%20think%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F706232%22%20target%3D%22_blank%22%3E%40Kyle_P19%3C%2FA%3E%26nbsp%3Bwas%20looking%20for%20a%20running%20total%20in%20the%20Total%20column%2C%20but%20a%20quick%20adjustment%20in%20the%20first%20row%20of%20the%20total%20column%20to%20this%3A%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-excel%22%3E%3CCODE%3E%3DSUMPRODUCT(%24D%246%3AD6%2C%24E%246%3AE6)%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3Eand%20then%20dragged%20down%20to%20the%20range%20of%20the%20cells%2C%20would%20achieve%20that.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1517395%22%20slang%3D%22en-US%22%3ERe%3A%20Saving%20reference%20down%20a%20column%20as%20its%20reference%20is%20changed%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1517395%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F706232%22%20target%3D%22_blank%22%3E%40Kyle_P19%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAnother%20approach%20to%20this%20is%20to%20use%20named%20tables%20to%20ensure%20that%20the%20validation%20lists%20grow%20as%20more%20priced%20items%20are%20available%20and%20to%20ensure%20that%20new%20sales%20rows%20include%20all%20relevant%20formulas.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ETo%20convert%20a%20range%20of%20data%20to%20a%20table%2C%20you%20can%20use%20Ctrl%2BT.%20You%20can%20then%20go%20to%20the%20Table%20Design%20tab%20and%20on%20the%20far-left%20of%20the%20ribbon%2C%20give%20the%20table%20a%20name.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20created%20two%20tables%3A%3C%2FP%3E%3CP%3E1.%20sales%3C%2FP%3E%3CP%3E2.%20prices%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20sales%20table%20is%20where%20I%20record%20the%20items%20and%20quantities%20sold.%20There%20are%20formulas%20to%20lookup%20the%20correct%20price%20and%20calculate%20the%20line%20item%20amount.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAt%20the%20top%20of%20the%20sheet%2C%20there's%20a%20formula%20to%20calculate%20the%20sub-total%20of%20the%20sales%20lines.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22salesprices.gif%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F204846i559166F683B64F8D%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22salesprices.gif%22%20alt%3D%22salesprices.gif%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
New Contributor

Hello,

I would like to calculate total sales amounts by simply typing the number of sales, and using a selector box to determine the product being sold, and thus the amount made on the sale.

My problem is that when i change the product being sold, it changes the amount of past sales as well.

I've included a small file as an example.

 

I'd like to enter a new number to cells D6:D10 as sales are made, and select the product being sold at the time through the drop down list in E1.

Then I'd like the price of the product to be automatically entered in column E6:E10, and remain even after selecting a new product in the drop down box.

Any code or design suggestions are greatly appreciated.

Kyle Parenzan

 

4 Replies
Highlighted

@Kyle_P19 

 

See the attached for one solution.

You just needed to make the drop down part of the row in which the calc took place.  And assuming your real world application has more than two products, use VLOOKUP rather than your IF formulation to determine the per unit price.

Highlighted
bonjour, quand je voulais imprimer et convertir en pdf, je ne vois pas la page entier, sur exel,
Highlighted

@mathetes 

 

This is the right solution to calculate line-item totals providing the intention of Number of Sales is "units sold" and not "line item / row number" (it's not clear to me which is intended tbh).

 

Additionally, I think @Kyle_P19 was looking for a running total in the Total column, but a quick adjustment in the first row of the total column to this:

=SUMPRODUCT($D$6:D6,$E$6:E6)

and then dragged down to the range of the cells, would achieve that.

Highlighted

@Kyle_P19 

 

Another approach to this is to use named tables to ensure that the validation lists grow as more priced items are available and to ensure that new sales rows include all relevant formulas.

 

To convert a range of data to a table, you can use Ctrl+T. You can then go to the Table Design tab and on the far-left of the ribbon, give the table a name.

 

I created two tables:

1. sales

2. prices

 

The sales table is where I record the items and quantities sold. There are formulas to lookup the correct price and calculate the line item amount.

 

At the top of the sheet, there's a formula to calculate the sub-total of the sales lines.

 

salesprices.gif