Excel Superheros,
I have a conundrum and need a hero.
I am trying to create a VBA code that 1) detects the first empty cell in a row then 2) reads the value of the cell several rows down (Apple price score cell), 3) copies the value of a cell on a different row (price cell) and pastes it the number of times down a row that was in the score cell.
For example, if an apple price has a score of 4 (row 9), the guidance is to purchase apples at that price for 2 months (row 2). After that contract, we contract the next # of months based on the purchase guidance based on how expensive apples are that month. If they are cheaper, usually we contract the price to buy them at that price for more months. Below is an example: since apples were a little expensive in Jan 2016 (score of 4), guidance was to contract that price for two months (see "If score" is 4, "Then buy this many months" is 2). After those two months, we need to buy again in March. The price score was 2 so we bought for 4 months at that price. Et cetera.
[TABLE="class: grid, width: 1000, align: center"]
<tbody>[TR]
[TD]If score[/TD]
[TD]1[/TD]
[TD]2[/TD]
[TD]3[/TD]
[TD]4[/TD]
[TD]5[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Then buy this many months[/TD]
[TD]5[/TD]
[TD]4[/TD]
[TD]3[/TD]
[TD]2[/TD]
[TD]1[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD]1/16[/TD]
[TD]2/16[/TD]
[TD]3/16[/TD]
[TD]4/16[/TD]
[TD]5/16[/TD]
[TD]6/16[/TD]
[TD]7/16[/TD]
[TD]8/16[/TD]
[TD]9/16[/TD]
[TD]10/16[/TD]
[TD]11/16[/TD]
[TD]12/16[/TD]
[/TR]
[TR]
[TD]Apple price[/TD]
[TD]$1.40[/TD]
[TD]$1.20[/TD]
[TD]$1.20[/TD]
[TD]$1.30[/TD]
[TD]$1.20[/TD]
[TD]$1.00[/TD]
[TD]$1.30[/TD]
[TD]$1.40[/TD]
[TD]$1.20[/TD]
[TD]$1.40[/TD]
[TD]$1.40[/TD]
[TD]$1.20[/TD]
[/TR]
[TR]
[TD]other item price[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]other item price[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Apple price score[/TD]
[TD]4[/TD]
[TD]2[/TD]
[TD]2[/TD]
[TD]3[/TD]
[TD]2[/TD]
[TD]1[/TD]
[TD]3[/TD]
[TD]4[/TD]
[TD]2[/TD]
[TD]3[/TD]
[TD]4[/TD]
[TD]2[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Apple price if following score guidance[/TD]
[TD]$1.40[/TD]
[TD]$1.40[/TD]
[TD]$1.20[/TD]
[TD]$1.20[/TD]
[TD]$1.20[/TD]
[TD]$1.20[/TD]
[TD]$1.30[/TD]
[TD]$1.30[/TD]
[TD]$1.30[/TD]
[TD]$1.40[/TD]
[TD]$1.40[/TD]
[TD]$1.20[/TD]
[/TR]
</tbody>[/TABLE]
I have 10 items that I am testing over several years. I want to see the price affect on the items if the guidance on the number of months changes (row 2).
Since I plan to test several dozen options, putting this into a macro would save me probably over a week of work and really help me in my goals to improve my VBA.
I really appreciate it!
I have a conundrum and need a hero.
I am trying to create a VBA code that 1) detects the first empty cell in a row then 2) reads the value of the cell several rows down (Apple price score cell), 3) copies the value of a cell on a different row (price cell) and pastes it the number of times down a row that was in the score cell.
For example, if an apple price has a score of 4 (row 9), the guidance is to purchase apples at that price for 2 months (row 2). After that contract, we contract the next # of months based on the purchase guidance based on how expensive apples are that month. If they are cheaper, usually we contract the price to buy them at that price for more months. Below is an example: since apples were a little expensive in Jan 2016 (score of 4), guidance was to contract that price for two months (see "If score" is 4, "Then buy this many months" is 2). After those two months, we need to buy again in March. The price score was 2 so we bought for 4 months at that price. Et cetera.
[TABLE="class: grid, width: 1000, align: center"]
<tbody>[TR]
[TD]If score[/TD]
[TD]1[/TD]
[TD]2[/TD]
[TD]3[/TD]
[TD]4[/TD]
[TD]5[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Then buy this many months[/TD]
[TD]5[/TD]
[TD]4[/TD]
[TD]3[/TD]
[TD]2[/TD]
[TD]1[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD]1/16[/TD]
[TD]2/16[/TD]
[TD]3/16[/TD]
[TD]4/16[/TD]
[TD]5/16[/TD]
[TD]6/16[/TD]
[TD]7/16[/TD]
[TD]8/16[/TD]
[TD]9/16[/TD]
[TD]10/16[/TD]
[TD]11/16[/TD]
[TD]12/16[/TD]
[/TR]
[TR]
[TD]Apple price[/TD]
[TD]$1.40[/TD]
[TD]$1.20[/TD]
[TD]$1.20[/TD]
[TD]$1.30[/TD]
[TD]$1.20[/TD]
[TD]$1.00[/TD]
[TD]$1.30[/TD]
[TD]$1.40[/TD]
[TD]$1.20[/TD]
[TD]$1.40[/TD]
[TD]$1.40[/TD]
[TD]$1.20[/TD]
[/TR]
[TR]
[TD]other item price[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]other item price[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Apple price score[/TD]
[TD]4[/TD]
[TD]2[/TD]
[TD]2[/TD]
[TD]3[/TD]
[TD]2[/TD]
[TD]1[/TD]
[TD]3[/TD]
[TD]4[/TD]
[TD]2[/TD]
[TD]3[/TD]
[TD]4[/TD]
[TD]2[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Apple price if following score guidance[/TD]
[TD]$1.40[/TD]
[TD]$1.40[/TD]
[TD]$1.20[/TD]
[TD]$1.20[/TD]
[TD]$1.20[/TD]
[TD]$1.20[/TD]
[TD]$1.30[/TD]
[TD]$1.30[/TD]
[TD]$1.30[/TD]
[TD]$1.40[/TD]
[TD]$1.40[/TD]
[TD]$1.20[/TD]
[/TR]
</tbody>[/TABLE]
I have 10 items that I am testing over several years. I want to see the price affect on the items if the guidance on the number of months changes (row 2).
Since I plan to test several dozen options, putting this into a macro would save me probably over a week of work and really help me in my goals to improve my VBA.
I really appreciate it!