Use VBA to Solve Stocking Problem

sroberts

New Member
Joined
Nov 25, 2008
Messages
4
Hello -

I have a simple sheet with columns holding product, gross_margin, and rank. The rank is calculated using the Excel Rank formula. In a fourth column named ShelfLocation, I want to start allocating where the product will go on the shelf - low, middle or high. All of the products are in the same size case, so I have a very simple problem of getting X amount of shelf space filled with Y amount of product. The Low shelf is the premium shelf where I want to put my best margin items. Here is the problem...

Let's assume I have 32 cases of LOW shelf area. When I rank the product and sort by this Rank column I end up with 1,2,3... 29,30,30,31,31,31,32,32,33,33,33,33 etc. In otherwords the Rank delivers duplicate values. So my simple running balance forumla to assign LOW to a shelf over-allocates the shelf (my forumula read in part If (Rank <= 32, "Low", if...)).

The number of items and available shelf space is variable by store. So I am wanting a VBA solution that will loop through the sheet based upon Rank, and set the ShelfLocation cell based upon a maximum available shelf space, then filling the next shelf space to its maximum, and finally the top space with the remainder of items.

Any help providing a general outline of the code would be greatly helpful.

Thanks,
Steve
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.

Forum statistics

Threads
1,214,923
Messages
6,122,283
Members
449,075
Latest member
staticfluids

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