If Then Statement

Hoosier03

Board Regular
Joined
Apr 29, 2011
Messages
121
I am using excel 2007. I have 3 worksheets. One worksheet has the starting inventory. One worksheet has the current inventory. One worksheet has the sales. How do I write an If/Then statement so if there is a sale entered anywhere in the sales sheet it subtracts out the sale and records it to the current inventory sheet?


Here is what I first wrote.

=IF(store_tracker!D2='current inventory'!B3,'starting inventory'!E3-store_tracker!F2,'starting inventory'!E3)


I then changed it to

=IF(store_tracker!D2:D15000='current inventory'!B3,'starting inventory'!E3-store_tracker!F2,'starting inventory'!E3)

That does not subtract out any of the entries because there are not "blue long sleeve shirts" entries in every cell.


Thanks
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
Hi Hoosier,
Can you put some of your data?
A leyout for all 3 sheet?

The solution is probably simple but is hard to read your formulas.
 
Upvote 0
Starting Inventory

Price Small Medium Large
Blue Long Sleeve Shirt 30 8 9 7
Red Long Sleeve Shirt 30 9 10 8



Sales Sheet

Item Purchased Size Quantity
Blue Long Sleeve Shirt Small 3
Red Long Sleeve Shirt Medium 2
Red Long Sleeve Shirt Small 4


Current Inventory



Price Small Medium Large
Blue Long Sleeve Shirt 30 4 3 5
Red Long Sleeve Shirt 30 4 9 6


I need the current inventory to update anytime there is an entry for the product done in the sales sheet.


Thanks,
 
Upvote 0
See if this gives you an idea:

<b>Excel 2007</b><table cellpadding="2.5px" rules="all" style=";background-color: #FFFFFF;border: 1px solid;border-collapse: collapse; border-color: #A6AAB6"><colgroup><col width="25px" style="background-color: #E0E0F0" /><col /><col /><col /><col /><col /></colgroup><thead><tr style=" background-color: #E0E0F0;text-align: center;color: #161120"><th></th><th>A</th><th>B</th><th>C</th><th>D</th><th>E</th></tr></thead><tbody><tr ><td style="color: #161120;text-align: center;">1</td><td style=";">Starting Inventory</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: #161120;text-align: center;">2</td><td style="text-align: right;;"></td><td style=";">Price</td><td style=";">Small</td><td style=";">Medium</td><td style=";">Large</td></tr><tr ><td style="color: #161120;text-align: center;">3</td><td style=";">Blue Long Sleeve Shirt</td><td style="text-align: right;;">30</td><td style="text-align: right;;">8</td><td style="text-align: right;;">9</td><td style="text-align: right;;">7</td></tr><tr ><td style="color: #161120;text-align: center;">4</td><td style=";">Red Long Sleeve Shirt</td><td style="text-align: right;;">30</td><td style="text-align: right;;">9</td><td style="text-align: right;;">10</td><td style="text-align: right;;">8</td></tr><tr ><td style="color: #161120;text-align: center;">5</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: #161120;text-align: center;">6</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: #161120;text-align: center;">7</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: #161120;text-align: center;">8</td><td style=";">Sales Sheet</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: #161120;text-align: center;">9</td><td style=";">Item Purchased</td><td style=";">Size</td><td style=";">Quantity</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: #161120;text-align: center;">10</td><td style=";">Blue Long Sleeve Shirt</td><td style=";">Small</td><td style="text-align: right;;">3</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: #161120;text-align: center;">11</td><td style=";">Red Long Sleeve Shirt</td><td style=";">Medium</td><td style="text-align: right;;">2</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: #161120;text-align: center;">12</td><td style=";">Red Long Sleeve Shirt</td><td style=";">Small</td><td style="text-align: right;;">4</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: #161120;text-align: center;">13</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: #161120;text-align: center;">14</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: #161120;text-align: center;">15</td><td style=";">Current Inventory</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: #161120;text-align: center;">16</td><td style="text-align: right;;"></td><td style=";">Price</td><td style=";">Small</td><td style=";">Medium</td><td style=";">Large</td></tr><tr ><td style="color: #161120;text-align: center;">17</td><td style=";">Blue Long Sleeve Shirt</td><td style="text-align: right;;">30</td><td style="text-align: right;;">5</td><td style="text-align: right;;">9</td><td style="text-align: right;;">7</td></tr><tr ><td style="color: #161120;text-align: center;">18</td><td style=";">Red Long Sleeve Shirt</td><td style="text-align: right;;">30</td><td style="text-align: right;;">5</td><td style="text-align: right;;">8</td><td style="text-align: right;;">8</td></tr></tbody></table><table cellpadding="2.5px" rules="all" style=";background-color: #FFFFFF;border: 1px solid;border-collapse: collapse; border-color: #A6AAB6"><thead><tr style="background-color: #E0E0F0;text-align: center;color: #161120"><th><b>Sheet1</b></th></tr></td></thead></table><br /><br /><table width="85%" cellpadding="2.5px" rules="all" style=";border: 2px solid black;border-collapse:collapse;padding: 0.4em;background-color: #FFFFFF" ><tr><td style="padding:6px" ><b>Worksheet Formulas</b><table cellpadding="2.5px" width="100%" rules="all" style="border: 1px solid;text-align:center;background-color: #FFFFFF;border-collapse: collapse; border-color: #A6AAB6"><thead><tr style=" background-color: #E0E0F0;color: #161120"><th width="10px">Cell</th><th style="text-align:left;padding-left:5px;">Formula</th></tr></thead><tbody><tr><th width="10px" style=" background-color: #E0E0F0;color: #161120">C17</th><td style="text-align:left">=INDEX(<font color="Blue">$C$3:$E$4,MATCH(<font color="Red">$A17,$A$3:$A$4,0</font>),MATCH(<font color="Red">C$16,$C$2:$E$2,0</font>)</font>)-SUMPRODUCT(<font color="Blue">--(<font color="Red">$A$10:$A$12=$A17</font>),--(<font color="Red">$B$10:$B$12=C$16</font>),$C$10:$C$12</font>)</td></tr><tr><th width="10px" style=" background-color: #E0E0F0;color: #161120">D17</th><td style="text-align:left">=INDEX(<font color="Blue">$C$3:$E$4,MATCH(<font color="Red">$A17,$A$3:$A$4,0</font>),MATCH(<font color="Red">D$16,$C$2:$E$2,0</font>)</font>)-SUMPRODUCT(<font color="Blue">--(<font color="Red">$A$10:$A$12=$A17</font>),--(<font color="Red">$B$10:$B$12=D$16</font>),$C$10:$C$12</font>)</td></tr><tr><th width="10px" style=" background-color: #E0E0F0;color: #161120">E17</th><td style="text-align:left">=INDEX(<font color="Blue">$C$3:$E$4,MATCH(<font color="Red">$A17,$A$3:$A$4,0</font>),MATCH(<font color="Red">E$16,$C$2:$E$2,0</font>)</font>)-SUMPRODUCT(<font color="Blue">--(<font color="Red">$A$10:$A$12=$A17</font>),--(<font color="Red">$B$10:$B$12=E$16</font>),$C$10:$C$12</font>)</td></tr></tbody></table></td></tr></table><br />
 
Upvote 0
I ended up using Sumproduct for the whole equation. I could not get index and match to work. Thanks for your help


='starting inventory'!E4-SUMPRODUCT((store_tracker!$D$2:$D$15000='current inventory'!$B4)*(store_tracker!$E$2:$E$15000='current inventory'!E$2)*store_tracker!$F$2:$F$15000)+SUMPRODUCT((Audit!$B$2:$B$1500 0='current inventory'!$B4)*(Audit!$C$2:$C$15000='current inventory'!E$2)*Audit!$D$2:$D$15000)
 
Upvote 0

Forum statistics

Threads
1,224,520
Messages
6,179,267
Members
452,902
Latest member
Knuddeluff

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top