On Apr 5, 10:16 am, wrote:
Hi all,
I'm very new to VB for Excel and could use some help from experienced
users. I have a worksheet that contains the probability for developing
20 different diseases. If I know how many people are in my population,
I want to determine how many of those people will develop each
disease. Basically, I want to write one formula with a variable that
can be changed depending on the disease, for example, Num(disease) =
probability(disease) * people. The key is that I want to say something
like "run this code for my list of 20 diseases, replacing the word
'disease' above with the name of each disease.
Does this make sense, and is it easily done in VB?
I can't see why you would need
VB, although it would be
straightforward if I understand your problem. However, I think you can
achieve what you say you want in a worksheet.
Say you have "Malaria" in cell A2 and 0.25 (as the probability) in B2.
Now let's put our population figure in C1. In C2, put the following
formula: =$C$1 * B2. If you put 1000000 in C1, then C2 should display
250000. Add diseases and probabilities in columns A and B below the
first one and copy C2 to the new rows - the calculation should update
for each, the $ signs in $C$1 will keep the reference to the
population figure pointing to the correct value.
Of course, the result is not the number who *will* develop the
disease, it's just the mathematical expectation...
HTH
Mike