Ok, I am not overly sure here where the problem may lay.
The task I have is this.
I have a number of houses & a number of water plants (as in water processing plants, not the green kind!)
Each water plant can provide a certain % water coverage to all properties.
'All Properties' is classed as the number of houses + the number of water plants.
The 'coverage' as a percentage is given by the formula:
My problem is that I want to be able to work out how many Water Plants are needed to provide a certain coverage (80%) to the properties that I have.![]()
Please Login or Register to view this content.
The 'hiccup' here of course is that once you add those Water Plants, then the number of properties will increase by that amount, which may in turn mean that you need more Water Plants
So, the task that I have done, is to take the original formula and translate it so that it gives me 'Water Plants' based on a coverage of 80:
I've then wrapped this up in an interative loop.![]()
Please Login or Register to view this content.
The problem that I have is that if I feed my original formula with the amount of water plants that my new formula says I would need for 80% coverage, it always seems to come out at 81 or something around 80, but NOT 80. (It doesn't have to be exactly 80, it can be 79.xxxxxxxx or 80.xxxxxxx, and as long as it is that consitently I will use roundup, or rounddown).
I don't see why I am not getting back to my original figure of 80
Perhaps someone can take a look and just check if the formula translation, and the resulting code are good, and if so, perhaps see what is going on?
I've attached an example workbook. To run the macro just change the number of 'Houses' in B1. This will give a figure in B7. Feeding that figure back into B2 (as an integer) SHOULD make B6 and C6 equal 80(ish) (but it doesn't).
B6 is calculated using spreadsheet formula, and C6 is calculated using VBA formula just to check that there were no differences between the 2.
Many thanks
NB: Sub Do_Events() is there purely as an assistance in case you abort the macro when Application.EnableEvents=FALSE.
Bookmarks