SOLVED

Delete cell contents based on the condition of another cell

%3CLINGO-SUB%20id%3D%22lingo-sub-2621786%22%20slang%3D%22en-US%22%3EDelete%20cell%20contents%20based%20on%20the%20condition%20of%20another%20cell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2621786%22%20slang%3D%22en-US%22%3E%3CP%3EHello%2C%20I%20am%20creating%20a%20inventory%20management%20system.%20The%20page%20in%20question%20is%20on%20my%20Stock%20Out%20page.%20This%20page%20has%20the%20following%20column%20headings%3A%20DATE%2C%20SALES%20ORDER%2C%20CODE%2C%20NAME%2C%20UNITS%2C%20VALUE%20PER%20UNIT%2C%20TOTAL%20VALUE%2C%20SALES%20PRICE%2C%20TAX%20RATE%2C%20TAX%20COLLECTED%2C%20TOTAL%20SALE%2C%20PROFITS.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20area%20I%20am%20focused%20on%20is%20when%20I%20put%20in%20the%20code%20which%20is%20basically%20a%20SKU%2C%20the%20name%20pops%20up.%20I%20then%20enter%20how%20many%20units%20of%20that%20item%20sold.%20At%20that%20point%20all%20of%20the%20calculations%20are%20performed%20returning%20my%20profit%20from%20the%20transaction.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20inventory%20management%20system%20is%20for%20a%20new%20business%20so%20it's%20not%20being%20100%25%20used%20at%20this%20point.%20However%2C%20my%20main%20focus%20is%20on%20Code%20and%20Units.%20When%20I%20delete%20an%20entry%20by%20removing%20the%20value%20under%20Code%2C%20all%20other%20cells%20get%20deleted%20except%20for%20Units.%20Since%20the%20sheet%20is%20so%20large%2C%20with%20lots%20of%20cells%20and%20columns.%20It%20can%20be%20difficult%20to%20realize%20that%20the%20unit%20column%20still%20contains%20a%20value%20from%20a%20previous%20entry.%20I%20would%20like%20for%20the%20Unit%20cell%20to%20be%20deleted%20if%20the%20Code%20cell%20is%20deleted%20or%20already%20blank.%20Is%20this%20possible%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2621786%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-2621844%22%20slang%3D%22en-US%22%3ERe%3A%20Delete%20cell%20contents%20based%20on%20the%20condition%20of%20another%20cell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2621844%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1122490%22%20target%3D%22_blank%22%3E%40Jlwiv87%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI'm%20fairly%20sure%20that%20something%20like%20that%20is%20possible.%20%3CU%3E%3CSTRONG%3EHOWEVER%3C%2FSTRONG%3E%3C%2FU%3E%2C%20for%20the%20sake%20of%20data%20integrity%2C%20wouldn't%20it%20make%20more%20sense%20to%20keep%20history%20of%20codes%20and%20units%20that%20did%20exist%20even%20after%20you've%20deleted%20(I%20assume%20discontinued)%20an%20item%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20speak%20as%20the%20former%20director%20of%20the%20HR%2FPayroll%20database%20for%20a%20major%20corporation.%20We%20would%20have%20employees%20resign%2C%20retire%2C%20be%20terminated%2C%20etc%2C%20(to%20say%20nothing%20of%20move%20from%20one%20job%2C%20one%20location%2C%20to%20another).%20We%20kept%20history%20of%20all%20employees%20and%20their%20positions%2C%20past%20and%20present%2C%20and%20yet%20could%20always%20produce%20an%20instant%20snapshot%20of%20who%20was%20%26nbsp%3Bwhere%20at%20any%20given%20time.%20It's%20from%20a%20logical%20point%20of%20view%20not%20dissimilar%20from%20an%20inventory%20system.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20also%20have%20a%20brother-in-law%20who%20has%20a%20small%20business.%20I%20helped%20him%20and%20his%20partner%20create%20their%20inventory%20system%2C%20SKUs%20and%20all.....it%20stores%20history%20as%20well%20as%20current%20data.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIf%20I%20were%20consulting%20with%20you--and%20I'm%20not%2C%20I'm%20retired%20and%20happily%20just%20volunteering%20some%20time%20here--but%20if%20I%20were%20consulting%20with%20you%20I'd%20seriously%20recommend%20keeping%20the%20history%20of%20SKUs%20past%20and%20present%2C%20and%20dates%20and%20quantities%20of%20transactions.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EBy%20the%20way%2C%20it%20always%20helps%20to%20post%20a%20copy%20of%20whatever%20workbook%20you're%20asking%20about.%20It%20helps%20those%20of%20us%20who%20want%20to%20help%20know%20more%20precisely%20what%20you're%20dealing%20with.%20If%20it's%20proprietary%2C%20consider%20making%20a%20small%20mockup%20with%20false%20names%2C%20but%20the%20same%20layout.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2621982%22%20slang%3D%22en-US%22%3ERe%3A%20Delete%20cell%20contents%20based%20on%20the%20condition%20of%20another%20cell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2621982%22%20slang%3D%22en-US%22%3EHi%2C%20thanks%20for%20your%20quick%20response.%20I%20will%20try%20and%20get%20a%20mockup%20posted%20soon.%20I%20understand%20what%20you%20were%20saying%20as%20far%20as%20retaining%20data.%20However%2C%20when%20I%20say%20I%20delete%20an%20entry%20I'm%20just%20referring%20to%20me%20testing%20my%20sheet%20to%20make%20sure%20all%20formulas%20are%20working%20correctly.%20So%20in%20doing%20so%20I've%20noticed%20when%20I%20delete%20the%20value%20under%20Code%2C%20then%20the%20only%20remaining%20information%20on%20the%20sheet%20is%20under%20Units.%20So%20I%20then%20need%20to%20manually%20erase%20Units%20but%20I%20would%20like%20some%20kind%20of%20automatic%20function%20here%2C%20in%20case%20I%20forget%20to%20delete%20it%20on%20my%20own.%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2622083%22%20slang%3D%22en-US%22%3ERe%3A%20Delete%20cell%20contents%20based%20on%20the%20condition%20of%20another%20cell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2622083%22%20slang%3D%22en-US%22%3ESo%20I%20have%20posted%20the%20workbook.%20So%20to%20help%20with%20my%20issue%20you%20would%20go%20to%20the%20Stock%20Out%20tab.%20Under%20the%20CODE%20column%20enter%20any%20number%20from%201-105%2C%20then%20press%20tab%20twice%20to%20enter%20how%20many%20units%20sold%2C%20let's%20say%202.%20Then%20you%20will%20see%20the%20rest%20of%20the%20calculations%20unfold.%20Then%20say%20you%20wanted%20to%20erase%20that%20entry.%20You%20would%20go%20back%20under%20CODE%20and%20hit%20delete.%20All%20other%20information%20would%20then%20be%20gone%2C%20except%20for%20the%20value%20under%20the%20Unit%20column.%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2622235%22%20slang%3D%22en-US%22%3ERe%3A%20Delete%20cell%20contents%20based%20on%20the%20condition%20of%20another%20cell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2622235%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1122490%22%20target%3D%22_blank%22%3E%40Jlwiv87%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWow.%20That's%20quite%20an%20ambitious%20workbook.%20If%20we%20were%20sitting%20down%20face-to-face%20I'd%20want%20to%20back%20up%20a%20bit%2C%20maybe%20simplify%20things.%20Maybe%20not.%20As%20to%20the%20question%20you%20came%20asking%20about%2C%20can%20we%20put%20that%20aside%20for%20the%20moment%3F%20What%20you%20might%20want%20to%20consider%20is%20just%20highlighting%20the%20columns%20into%20which%20you%20actually%20enter%20data%20or%20numbers...highlight%20them%20in%20a%20different%20color%2C%20so%20as%20to%20differentiate%20them%20from%20the%20columns%20where%20calculations%20are%20done.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThere%20was%20somebody%20else%20on%20this%20site%20creating%20an%20inventory%20system.%20That%20person%20had%20separate%20pages%20for%20each%20category%20of%20item%20(four%20or%20five%20of%20them).%20You%20have%20separate%20pages%20for%20different%20actions.%20I%20think%20I'd%20combine%20them%2C%20just%20noting%20on%20each%20row%20whether%20it%20was%20item%20IN%20or%20item%20OUT%20(or%20whatever%20other%20action%20categories%20you%20might%20have).%20I%20created%20an%20example%20for%20that%20person%20of%20a%20different%20approach.%20Take%20a%20look%20and%20see%20if%20it%20makes%20any%20sense.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2622910%22%20slang%3D%22en-US%22%3ERe%3A%20Delete%20cell%20contents%20based%20on%20the%20condition%20of%20another%20cell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2622910%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%3BI%20like%20the%20more%20simplified%20approach%20you%20have%20there.%20However%2C%20I've%20spent%20quite%20a%20bit%20of%20time%20on%20my%20currently%20workbook%2C%20and%20just%20seem%20to%20be%20hung%20up%20on%20this%20one%20issue.%20I%20would%20like%20to%20find%20a%20solution%20to%20this%20issue%20if%20there%20is%20one.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThis%20is%20my%20first%20attempt%20at%20this%2C%20as%20well%20as%20my%20first%20official%20business.%20Since%2C%20you%20have%20a%20lot%20of%20experience%20in%20this%20area.%20Do%20you%20think%20I'm%20on%20the%20right%20track.%20Is%20there%20any%20other%20useful%20bits%20of%20information%20I%20should%20add%20to%20this%20workbook%3F%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThis%20business%20will%20be%20starting%20off%20online%2C%20until%20we're%20able%20to%20open%20up%20a%20brick-and-mortar%20location.%20I'm%20Hoping%20this%20workbook%20will%20serve%20my%20needs%20as%20the%20business%20continues%20to%20grow.%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2622985%22%20slang%3D%22en-US%22%3ERe%3A%20Delete%20cell%20contents%20based%20on%20the%20condition%20of%20another%20cell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2622985%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1122490%22%20target%3D%22_blank%22%3E%40Jlwiv87%3C%2FA%3E%26nbsp%3BAllow%20me%20to%20address%20your%20specific%20question%20regarding%20the%20STOCK%20OUT%20sheet%20only.%20I%20have%20converted%20the%20table%20to%20a%20structured%20table%20and%20added%20data%20validation%20to%20column%20C%20and%20changed%20the%20formulae%20in%20this%20sheet%20only%2C%20so%20that%20they%20use%20structured%20table%20reference.%20See%20attached.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAnd%20perhaps%20some%20tips%20for%20further%20development.%3C%2FP%3E%3CP%3E1)%20Do%20not%20use%20merged%20cells%3B%3C%2FP%3E%3CP%3E2)%20Use%20structured%20tables%20and%20structured%20references%20where%20possible%3B%3C%2FP%3E%3CP%3E3)%20Give%20meaningful%20names%20to%20these%20structured%20tables%3B%3C%2FP%3E%3CP%3E4)%20Do%20not%20add%20blank%20rows%20within%20or%20at%20the%20bottom%20of%20such%20tables%3B%3C%2FP%3E%3CP%3E5)%20Use%20data%20validation%20and%20VLOOKUP%20(or%20better%20XLOOKUP%20if%20your%20Excel%20version%20supports%20it)%20in%20all%20relevant%20sheets%20to%20match%20product%20codes%20with%20their%20names%2C%20qty%20and%20pricing%20information%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
Occasional Contributor

Hello, I am creating a inventory management system. The page in question is on my Stock Out page. This page has the following column headings: DATE, SALES ORDER, CODE, NAME, UNITS, VALUE PER UNIT, TOTAL VALUE, SALES PRICE, TAX RATE, TAX COLLECTED, TOTAL SALE, PROFITS. 

 

The area I am focused on is when I put in the code which is basically a SKU, the name pops up. I then enter how many units of that item sold. At that point all of the calculations are performed returning my profit from the transaction. 

 

The inventory management system is for a new business so it's not being 100% used at this point. However, my main focus is on Code and Units. When I delete an entry by removing the value under Code, all other cells get deleted except for Units. Since the sheet is so large, with lots of cells and columns. It can be difficult to realize that the unit column still contains a value from a previous entry. I would like for the Unit cell to be deleted if the Code cell is deleted or already blank. Is this possible?

 

 

 

 

 

 

12 Replies

@Jlwiv87 

 

I'm fairly sure that something like that is possible. HOWEVER, for the sake of data integrity, wouldn't it make more sense to keep history of codes and units that did exist even after you've deleted (I assume discontinued) an item?

 

I speak as the former director of the HR/Payroll database for a major corporation. We would have employees resign, retire, be terminated, etc, (to say nothing of move from one job, one location, to another). We kept history of all employees and their positions, past and present, and yet could always produce an instant snapshot of who was  where at any given time. It's from a logical point of view not dissimilar from an inventory system.

 

I also have a brother-in-law who has a small business. I helped him and his partner create their inventory system, SKUs and all.....it stores history as well as current data.

 

If I were consulting with you--and I'm not, I'm retired and happily just volunteering some time here--but if I were consulting with you I'd seriously recommend keeping the history of SKUs past and present, and dates and quantities of transactions.

 

By the way, it always helps to post a copy of whatever workbook you're asking about. It helps those of us who want to help know more precisely what you're dealing with. If it's proprietary, consider making a small mockup with false names, but the same layout.

Hi, thanks for your quick response. I will try and get a mockup posted soon. I understand what you were saying as far as retaining data. However, when I say I delete an entry I'm just referring to me testing my sheet to make sure all formulas are working correctly. So in doing so I've noticed when I delete the value under Code, then the only remaining information on the sheet is under Units. So I then need to manually erase Units but I would like some kind of automatic function here, in case I forget to delete it on my own.
So I have posted the workbook. So to help with my issue you would go to the Stock Out tab. Under the CODE column enter any number from 1-105, then press tab twice to enter how many units sold, let's say 2. Then you will see the rest of the calculations unfold. Then say you wanted to erase that entry. You would go back under CODE and hit delete. All other information would then be gone, except for the value under the Unit column.

@Jlwiv87 

 

Wow. That's quite an ambitious workbook. If we were sitting down face-to-face I'd want to back up a bit, maybe simplify things. Maybe not. As to the question you came asking about, can we put that aside for the moment? What you might want to consider is just highlighting the columns into which you actually enter data or numbers...highlight them in a different color, so as to differentiate them from the columns where calculations are done.

 

There was somebody else on this site creating an inventory system. That person had separate pages for each category of item (four or five of them). You have separate pages for different actions. I think I'd combine them, just noting on each row whether it was item IN or item OUT (or whatever other action categories you might have). I created an example for that person of a different approach. Take a look and see if it makes any sense.

 

 

@mathetes I like the more simplified approach you have there. However, I've spent quite a bit of time on my currently workbook, and just seem to be hung up on this one issue. I would like to find a solution to this issue if there is one.

 

This is my first attempt at this, as well as my first official business. Since, you have a lot of experience in this area. Do you think I'm on the right track. Is there any other useful bits of information I should add to this workbook? 

 

This business will be starting off online, until we're able to open up a brick-and-mortar location. I'm Hoping this workbook will serve my needs as the business continues to grow. 

@Jlwiv87 Allow me to address your specific question regarding the STOCK OUT sheet only. I have converted the table to a structured table and added data validation to column C and changed the formulae in this sheet only, so that they use structured table reference. See attached.

 

And perhaps some tips for further development.

1) Do not use merged cells;

2) Use structured tables and structured references where possible;

3) Give meaningful names to these structured tables;

4) Do not add blank rows within or at the bottom of such tables;

5) Use data validation and VLOOKUP (or better XLOOKUP if your Excel version supports it) in all relevant sheets to match product codes with their names, qty and pricing information;

 

 

 

 

 

best response confirmed by Jlwiv87 (Occasional Contributor)
Solution

@Jlwiv87 

You need to adopt the VBA approach to achieve this.

The attached file contains a Change_Event Code on Stock Out Sheet Module and as per the code, if you delete the Code in any row, the corresponding Unit will also be deleted.

 

Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo Skip
If Target.Column = 3 And Target.Row > 2 Then
    Application.EnableEvents = False
    If Target = "" Then
        Cells(Target.Row, "E") = ""
    End If
End If
Skip:
Application.EnableEvents = True
End Sub

 

 

 

Thanks for your response. I like what you've done to the table, and I will definitely use the tips you suggested as well. However, even though the sheet is a lot nicer now I still have the same problem. Once the Code is deleted the unit still remains, and needs to be manually removed.

After giving it some thought. I suppose it's alright if there's no solution available for this issue. As I do not plan on accepting returns with this business. So there would be no real need to delete any entries at all. This is just a small defect of this sheet that I came across when putting it together. And since I came across it I would like the issue to be resolved. But, I guess it still works nevertheless. The part that gets me though, is that it seems like there would be an easy solution.
That did the trick! Thank you so much for your help. I'm new to dealing with Excel and have heard about VBA, but haven't got around to using it yet. I will have to explore this more. Thank you for your time and effort!

@Jlwiv87 

 

I'm glad a couple of others with their expertise have joined in this thread. Let me just address a couple of the questions you asked me.

This is my first attempt at this, as well as my first official business. Since, you have a lot of experience in this area. Do you think I'm on the right track. Is there any other useful bits of information I should add to this workbook? 

I don't really have a lot of experience in this area. My working career (I'm long retired now) involved a stint as director of the HR/Payroll database for a major corporation. In connection with that I learned a lot about relational databases, the logical process known as "normalization"--which has the goal of eliminating redundancy in data--SQL (Structured Query Language, and the like. My experience with product inventory lists per se is next to zero, the worksheet I shared and another I did in conjunction with my brother-in-law's business.

It's that corporate experience that leads me to want to combine tables that essentially contain the same info, with just a small distinction, using a cell in each row (i.e., a column) to recognize that distinction. So in your case, for example, Opening Stock, Stock In, and Stock Out have many columns in common, despite representing different actions, different points in the process. That overlap (otherwise known as redundancy) raises red flags to my "normalization" mind. It may be appropriate (and it may not be) to combine them into a single table (with a column that represents how each row figures into the flow) and have another page that reflects "Current Stock" that is all calculated, Opening + StockIn - StockOut

 

Other than that, you look like you're on the right track. Take the recommendations of @Riny_van_Eekelen very seriously. It's a common mistake of beginners with Excel to spend more time on jazzing up the appearance of their spreadsheets--colors, combined cells, empty rows--that make it look nicer, cleaner, clearer to humans, but truly interfere with Excel's abilities to manipulate data. Learn to use structured tables.

 

This business will be starting off online, until we're able to open up a brick-and-mortar location. I'm Hoping this workbook will serve my needs as the business continues to grow. 

 

Best wishes to you. Will you be doing this on Shopify/Etsy/Wayfair (or all of them)? Or stand-alone? It's an exciting time, with the technology available today to make it possible to enter into a business and do sales world-wide. Check out https://www.carthage.co  It's my the business my brother in law has launched. Somewhat in the same niche as yours, home goods, but not a competitor.

You're welcome @Jlwiv87! Glad it worked as desired.

That's a beautiful site, very nice. I plan to sell on all of the mentioned platforms including locally, using Offer Up and Craigslist. I guess when you said Payroll, for some reason my mind went to Accounting. So I was just curious if I had enough useful information. So that in the future a CPA could use the information provided and have a clear picture of what's going on in the business.
Trying to Jazz up this Excel sheet is definitely something that I've been doing. And, as someone new to Excel it's taken me quite a bit of time. So I do I need to stop putting in so much time and energy there. The good thing is, I believe that was one of the last things I was hung up on. So now I can focus my efforts elsewhere. Thank you for your good wishes!