SOLVED

Formula/VBA Help

%3CLINGO-SUB%20id%3D%22lingo-sub-2979488%22%20slang%3D%22en-US%22%3EFormula%2FVBA%20Help%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2979488%22%20slang%3D%22en-US%22%3E%3CP%3EPlease%20assist%20me%20in%20below%20situation%3C%2FP%3E%3CP%3E%3CBR%20%2F%3EIn%20A%20column%2C%20I%20have%20a%20Quantity%20which%20are%20required%20to%20fill%20%22X%22%20store%2C%20but%20this%20should%20be%20fetch%20from%20other%20Stores%20lets%20say%201%2C2%2C3%2C4%2C5%2C6%3C%2FP%3E%3CP%3E%3CBR%20%2F%3ECondition%20is%20if%20my%20store%20%231%20has%20less%20qty%20than%20what%20I%20need%20in%20A%20column%20for%20store%20X%2C%20then%20it%20should%20return%20zero%20(should%20not%20give%20anything)%2C%20and%20run%20the%20logic%20in%20next%20column%20with%20different%20store.%3C%2FP%3E%3CP%3EBut%20if%20Quantity%20in%20Store%201%20is%20greater%20than%20what%20is%20required%20for%20Store%20X%2C%20then%20it%20should%20check%20the%20difference%20and%20assigned%20the%20quantities%20which%20is%20required%20by%20X%20store%20(nothing%20more).%3C%2FP%3E%3CP%3EIF%20store%20x%20need%2050%20qty%20but%20store%201%20only%20able%20to%20fulfil%2040%20then%20for%20remaining%2010%20quantities%20it%20will%20check%20in%20next%20store%20and%20so%20on.%3C%2FP%3E%3CP%3E%3CBR%20%2F%3ENote%3A%20if%20store%201%20has%20151%20quantity%20and%20can%20fulfil%20required%2050%20quantity%20for%20X%20store%20then%20it%20will%20only%20give%2050%20not%2051%2C%20and%20when%20formula%20move%20to%20anotehr%20colum%20then%20it%20should%20come%20as%200%2C%20cause%20required%20quantity%20is%20already%20fulfilled%20by%20previous%20stores.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2979488%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EFormulas%20and%20Functions%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EMacros%20and%20VBA%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2980838%22%20slang%3D%22en-US%22%3ERe%3A%20Formula%2FVBA%20Help%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2980838%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1222494%22%20target%3D%22_blank%22%3E%40sherikhan88%3C%2FA%3E%26nbsp%3BDon't%20think%20you%20need%20to%20%22Excess%22%20columns%2C%20by%20the%20way.%20And%20the%20logic%20you%20want%20to%20apply%20seems%20to%20cause%20trouble.%20You%20say%20that%20if%20Store1%20doesn't%20have%20enough%20on%20hand%2C%20it%20should%20be%20skipped%2C%20with%20the%20same%20logic%20applied%20to%20the%20following%20stores.%3C%2FP%3E%3CP%3ESuppose%20the%20quantity%20of%20the%20first%20order%20would%20be%20101%2C%20rather%20than%2047%2C%20then%20none%20of%20the%20stores%20would%20be%20selected.%20Wouldn't%20it%20make%20more%20sense%20to%20say%20that%20store%201%20delivers%2047%2C%20store2%2050%20and%20store%203%20the%20remaining%204.%20Or%2C%20store%203%20delivers%20all%20of%20their%2092%20items%20and%20store%201%20delivers%209%20more%20(or%20any%20other%20combination%20of%20stores%20for%20that%20matter).%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAnyhow%2C%20the%20attached%20file%20does%20what%20you%20ask%20for%2C%20unless%20I%20completely%20misunderstood.%20Note%20that%20I%20changed%20the%20formulae%20in%20the%20%22Excess%22%20columns%20to%20something%20without%20IF%2C%20hoping%20you%20find%20it%20useful.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2996677%22%20slang%3D%22en-US%22%3ERe%3A%20Formula%2FVBA%20Help%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2996677%22%20slang%3D%22en-US%22%3EHi%20Riny%2C%3CBR%20%2F%3E%3CBR%20%2F%3Efirst%20of%20all%20thank%20you%20so%20much%20to%20respond%20to%20my%20query%20and%20giving%20your%20valuable%20time.%3CBR%20%2F%3E%3CBR%20%2F%3E%22Wouldn't%20it%20make%20more%20sense%20to%20say%20that%20store%201%20delivers%2047%2C%20store2%2050%20and%20store%203%20the%20remaining%204%22%20yes%20this%20is%20what%20i%20need.%3CBR%20%2F%3E%3CBR%20%2F%3EI%20don't%20need%20excess%20column%20you%20are%20right%2C%20I%20just%20put%20it%20there%20to%20see%20what%20is%20the%20excess%20quantity%20in%201%20to%206%20stores%20from%20Column%20A%20(%20which%20is%20required%20in%20Store%20X).%3CBR%20%2F%3E%3CBR%20%2F%3ESo%20Store%20X%20need%20certian%20qty%20which%20is%20mentioned%20in%20column%20A%20which%20has%20to%20be%20fulfilled%20from%20rest%20of%206%20stores.%20Issue%20which%20i%20cannot%20able%20to%20solve%20is%2C%20if%20my%20fulfilment%20store%20will%20only%20contribute%20if%20they%20have%20extra%20quantity%20with%20them%20(%20greater%20than%20A%20column).%3CBR%20%2F%3E%3CBR%20%2F%3ELets%20Say%3CBR%20%2F%3E%3CBR%20%2F%3E1)%20Store%20X%20need%2048%20qty.%20My%20fulfilment%20store%201%2C2%2C3----%20has%2048%2C50%2C100%2C110%20qty%2C%20then%20formula%20should%20check%20what%20is%20the%20qty%20required%20by%20store%20x%20and%20then%20it%20started%20to%20go%20to%20every%20store%20and%20see%20if%20its%20more%20or%20less%20then%20required%20qty.%20then%20if%20its%20less%2C%20system%20will%20skip%20that%20store%2C%20if%20its%20more%20then%20it%20will%20metch%20the%20max%20quantity%20it%20can%20fetch%20to%20fulfil%20the%20requirement%20but%20not%20more%20then%20the%20requirement.%3CBR%20%2F%3E%3CBR%20%2F%3EPlease%20check%20the%20attached%20file.%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2996695%22%20slang%3D%22en-US%22%3ERe%3A%20Formula%2FVBA%20Help%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2996695%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F403176%22%20target%3D%22_blank%22%3E%40Riny_van_Eekelen%3C%2FA%3E%26nbsp%3BPFA%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2996844%22%20slang%3D%22en-US%22%3ERe%3A%20Formula%2FVBA%20Help%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2996844%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1222494%22%20target%3D%22_blank%22%3E%40sherikhan88%3C%2FA%3E%26nbsp%3BSorry%2C%20but%20I%20don't%20understand%20the%20logic%20of%20your%20desired%20result%2C%20but%20perhaps%20I%20misunderstood%20again.%20My%20formulae%20now%20look%20at%20Store%201%20first%20and%20fulfills%20the%20order%20with%20all%20it%20has.%20Then%20Store%202%20fulfills%20what's%20left%20and%20so%20on.%20So%20for%20the%20first%20order%2C%20Store%201%20fulfills%2047%20out%20of%2048%20and%20Store%202%20fulfills%201%20more.%20All%20other%20stores%20are%20zero.%3C%2FP%3E%3C%2FLINGO-BODY%3E
Occasional Contributor

Please assist me in below situation


In A column, I have a Quantity which are required to fill "X" store, but this should be fetch from other Stores lets say 1,2,3,4,5,6


Condition is if my store #1 has less qty than what I need in A column for store X, then it should return zero (should not give anything), and run the logic in next column with different store.

But if Quantity in Store 1 is greater than what is required for Store X, then it should check the difference and assigned the quantities which is required by X store (nothing more).

IF store x need 50 qty but store 1 only able to fulfil 40 then for remaining 10 quantities it will check in next store and so on.


Note: if store 1 has 151 quantity and can fulfil required 50 quantity for X store then it will only give 50 not 51, and when formula move to anotehr colum then it should come as 0, cause required quantity is already fulfilled by previous stores.

9 Replies

@sherikhan88 Don't think you need to "Excess" columns, by the way. And the logic you want to apply seems to cause trouble. You say that if Store1 doesn't have enough on hand, it should be skipped, with the same logic applied to the following stores.

Suppose the quantity of the first order would be 101, rather than 47, then none of the stores would be selected. Wouldn't it make more sense to say that store 1 delivers 47, store2 50 and store 3 the remaining 4. Or, store 3 delivers all of their 92 items and store 1 delivers 9 more (or any other combination of stores for that matter).

 

Anyhow, the attached file does what you ask for, unless I completely misunderstood. Note that I changed the formulae in the "Excess" columns to something without IF, hoping you find it useful.

Hi Riny,

first of all thank you so much to respond to my query and giving your valuable time.

"Wouldn't it make more sense to say that store 1 delivers 47, store2 50 and store 3 the remaining 4" yes this is what i need.

I don't need excess column you are right, I just put it there to see what is the excess quantity in 1 to 6 stores from Column A ( which is required in Store X).

So Store X need certian qty which is mentioned in column A which has to be fulfilled from rest of 6 stores. Issue which i cannot able to solve is, if my fulfilment store will only contribute if they have extra quantity with them ( greater than A column).

Lets Say

1) Store X need 48 qty. My fulfilment store 1,2,3---- has 48,50,100,110 qty, then formula should check what is the qty required by store x and then it started to go to every store and see if its more or less then required qty. then if its less, system will skip that store, if its more then it will metch the max quantity it can fetch to fulfil the requirement but not more then the requirement.

Please check the attached file.

@sherikhan88 Sorry, but I don't understand the logic of your desired result, but perhaps I misunderstood again. My formulae now look at Store 1 first and fulfills the order with all it has. Then Store 2 fulfills what's left and so on. So for the first order, Store 1 fulfills 47 out of 48 and Store 2 fulfills 1 more. All other stores are zero.

@Riny_van_Eekelen Thanks again.

 

I work in retial, we have item codes which needs to be allocated from warehouse to store. Lets say there are few item codes for which stock in warehouse is zero, and one of the store is selling those items alot due to which it runs out of stock, this is my X store and after doing some calculation my system tells that hey sheri, you X store need 47 qty for one week. 

Now, I do not have that item available in warehouse so the option is to fetch the stock from other store.
But other store also need some stock to sell (Minimum Display Quantity-MDQ), here in Column A (which is also the qty required by Store X) we mentioned the MDQ for all the remaining store.
I do not want to fecth anything extra from any store which is not meeting MDQ, and I also do not want to fetch anything extra if the quantity is fulfil. 

in my first example, My MDQ/or Store X requirement is 48.

My store 1 has 47 Qty available, since store 1 stock is less than 48, I do not want to consider this stock for donation.

Now I will check my second store, which has 50 qty, means 2 item extra. So system should take 2 items now the remaining qty required is (48-2=46), then i will see if my third store can fulfil it.

My third store has 92 qty= 92 is greater than 48, =92-48= 44. Store 3 can give 44 and i need 46, so we will take 44 from store 3, remaining quantity is =48-(2+44)= 2, so i will check store 4

 

My store 4 has 100 qty, and its greater than 48, so it can fulfil my requirement, but now i just need 2 qty. though it can give me 52. So here i want that i will only get 2 qtyamd when I go for next store, no matter how much qty it has it will say 0. 

best response confirmed by sherikhan88 (Occasional Contributor)
Solution

@sherikhan88 Quite some logic but I think I got it. See attached. It's an ugly formula and probably can be optimized. 

@Riny_van_Eekelen You're Awesome!!! Not only you understand and solved my issue. But gave your valuable time to me. 

I kept thinking about the solution for entire day, when i posted it but unable to put the logic into formulas. 

You will be remembered by rest of my generation ! Thank you for all you help.

I didnt even know, if we can use Max function like this

Genius

@sherikhan88 Glad it worked!!