Search:

# If and loop

Asked By: Pamela    Date: Nov 25    Category: MS Office    Views: 678

I have the following Formula in cell D38 = B29*((B31-G34))22

What is the value of G34 So that the formula (D38) =0

Always Values in Cell B29, B31, G34 > 0

Share:

I'm not sure what your precise formula  is, as there is a "2" at the end of
it and another "2" in a line by itself. Can I assume that those "2"s
shouldn't be there?

If so, this sounds like homework and like simple Algebra not Excel.
Therefore I won't supply the answer directly.

However, the formula appears to be a simple multiplication. To get the
result of a multiplication to be zero, then either or both sides of the
multiplication symbol must equal zero. You've said that B29 is not zero, so
... over to you.

Formula should read D38 = (B29*((B31-G34))**2)/2

Values in Cell B29, B31, G34 > 0
Regarding If then loop

I mean If range("D38").value <> 0 then ?

Etc.

The formula  you have given is not valid. Put the formula into a cell  in excel
and make sure it is valid, then ask us a question based on the real formula.

Hint - if you are doing programming in a language other than Excel VBA ask the
question on a forum for the language you are using. ** is not a valid
operator in excel.

I am terribly Sorry, you are right regarding ** it should be ^ the formula

D38 = (B29*((B31-G34)) ^2)/2

OK. So we know B31-G34 has to be 0 so what will G34 be to make that happen?

Only when B31=G34............................

Sorry, now I'm totally mystified.

Firstly, it sounds as though you are expecting to have a formula  that

Excel formulas do not have anything to the left of the equals sign. So, in
cell D38 you could have a formula =(B29*((B31-G34))**2)/2.

Well, you couldn't really, because ** is not an Excel operator. But you
could have =(B29*((B31-G34))*2)/2

Now that calculates a value to go into the cell  it's in, which might be D38,
or wherever you've put it.

What is an "If then loop"? An "If then" is a statement; a "loop" is an
entirely different statement. Additionally, Excel formulas do not have
loops; and they don't strictly have "If then", although they do have calls
to an IF function.

And what does "If range("D38").value <> 0 then ?" mean? For starters, that
is not a formula, it is part of a VBA statement.

As I indicated earlier, if you want to use a formula like the above to
produce a value of zero, then one side or other of the first multiplication
operator must be zero. This is Algebra, not Excel.

Just picked up on this thread.

The answer is very simple. Use GoalSeek with target cell  = D38, value =
0, cell to change = G34.

And if you want to do this in VBA, just record your steps, and then you
can automate it.

Didn't find what you were looking for? Find more on If and loop Or get search suggestion and latest updates.