# Solved Loop decreasing by 1 until 0 in excel

November 7, 2012 at 12:50:50
Specs: Windows 7
 I am creating a spreadsheet that has 3 different products and I am trying to find a loop that will decrease by 1 until there is not any products left or until there are no more projected customers left. product a has an inventory of 1900, product b has an inventory of 2200, and product c has an inventory of 1300. The total number of projected customers are 5000. Does anyone have any suggestions.

See More: Loop decreasing by 1 until 0 in excel

#1
November 7, 2012 at 13:43:04
 I, for one, have no idea what you are asking for.Creating "a loop" that decreases by 1 to 0 is easy:```Sub GoToZero() For myNum = 5000 to 0 Step -1 Next End Sub```There you go, a loop that starts at 5000 and decreases by 1 until it reaches 0. Of course, that loop is not related to your products or customers in any way.Please explain how you want this "loop" you speak of to interact with the other information you have provided.Click Here Before Posting Data or VBA Code ---> How To Post Data or Code.

Report •

#2
November 8, 2012 at 14:26:26
 The customers are split up into 2 groups the first group has 3000 customers and the second group has 2000 customers the first group will buy product c first the product b and then finally product a in that order until each product has 0 left or every customer has a product. The second group will buy product a first then product b in that order and they will not buy product c at all because of price. I was trying to create the loop to have the customers buy the products in the specified order with the first group to buy up the products first until every customer has made a purchase then the second group will buy products in their specified order until every customer has made a purchase or until no products are available, by my calculations every customer should be able to make a purchase and product b will have about 400 left over. I would guess that the loop should come up will the same result. I am new to using modules and really appreciate the help.

Report •

#3
November 8, 2012 at 15:27:07
 This sounds like a homework problem. By choice, we don't answer homework questions directly. We'll review what you've tried and help point you in the right direction, but you have to do some work on your own first.What have you tried so far?Click Here Before Posting Data or VBA Code ---> How To Post Data or Code.

Report •

Related Solutions

#4
November 9, 2012 at 12:56:31
 I have used simple formulas that reference from cell to cell to get the correct answer but I am trying to get help using a macro to make a button that will do the calculations to make the spreadsheet more user friendly. I am not asking for someone to do the work for me but rather help on how to program a macro.

Report •

#5
November 9, 2012 at 21:45:49
 I still don't understand what you want the macro to do. Do you want it to put formulas in cells for you? Do you want it to accept input from users about customers and products? Something totally different than either of those? What do want to happen when the button is clicked?A macro is a series of instructions that can do things to a spreadsheet or just do things within VBA and put the result in a cell or perhaps pop up a message box with a value. the possibilities are countless. Nothing that you've told us so far makes it clear what you expect the macro to do for you.I already posted an example of a countdown loop but without knowing how you are doing your current calculations we can't apply any kind of loop to your data.Give us an example of the layout of your spreadsheet and the formulas that you are using and we'll see if we can point you in the right direction.Before posting any example data, please click on the blue line at the bottom of this post and read the instructions on how to post data in this forum.In addition, if you DAGS on how to write excel macros you'll get lots of tips that should get you started.Click Here Before Posting Data or VBA Code ---> How To Post Data or Code.

Report •