Hello,
I have to write a macro for work that will check to see if a customer is saving at least 15% or more over our price. Using Excel I write a formula that does this:
=1-((retail price) / (list price)) then format that cell as a percentage.
I then alter the list price until the percentage goes up to 15%. I do this for rows and rows of products.
I'm just getting started on the script and to get familiar with VBA I made the following macro and it works for calculating the savings, but doesn't alter the list price for me.
[vba]
Option Explicit
Sub Savings()
Dim Savings As Single
Dim map_price As Single
Dim list_price As Single
map_price = Range("B2").Value
list_price = Range("A2").Value
Savings = 1 - (map_price / list_price)
Range("C2").Select
ActiveCell.FormulaR1C1 = Savings
Selection.NumberFormat = "0%"
End Sub
[/vba]
I found an example of a Do Until loop and thought I would use that to increment the list price until the condition of map_price + 15% is met, but I couldn't figure it out. If you want I can paste the code for the Do Until loop, but it's just botched at this point.
Question 1: What type of loop, if any, do I need to adjust the list price?
Question 2: Can you give me an example of how to use my existing code in a loop?
Thanks,
Dio