• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

VBA macro that changes two cell values based on one of the cell's inputs

Status
Not open for further replies.
Hi there, looking for some VBA help with a macro I want to write that does the following: suppose B1 has some number in it and I type a number into A1; if A1 is greater than or equal to 100*(B1+1), then the value in B1 goes up by 1 and the value in A1 goes down by 100*B1 (the new value in B1); otherwise, the program does nothing; and the program loops as necessary.

For example, suppose A1 = 1000 and B1 = 2; since 1000 >= 100*(2 + 1), B1 goes up to 3 and A1 goes down to 700. Since we now have A1 = 700 and B1 = 3, the program would run again because 700 >= 100*(3 + 1), so B1 goes up to 4 and A1 goes down to 300. Now that A1 = 300 and B1 = 4, the values don't satisfy the conditions to do anything so the values stay put until I change the value of A1.

This is my first time trying to use VBA (most everything I've done with Excel can be handled by Boolean operators) so I'm trash with VBA syntax; providing the code would be awesome, providing explanation about what the code is doing would be next-level amazing so I can try and understand how the VBA syntax works.
 
Last edited:
Status
Not open for further replies.
Back
Top