ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Finding Values of X (https://www.excelbanter.com/excel-programming/414216-finding-values-x.html)

Jeffrey[_2_]

Finding Values of X
 
Good day,

im just a newbie in VBA, i wonder if we can find X using VBA codes to
satisfy the equation below.

X^2 -28X+16 = 0.

Basically i want to find the value of X so that the left side of the
equation is equal to zero.

Thanks in advance.

RB Smissaert

Finding Values of X
 
In Cell C1 put this formula:
= A1* (28-A1)

Load Solver by doing Tools, Add-ins and tick the Solver add-in.

Then Tools, Solver and

Set Target Cell C1
Equal to value of -16
By changing value of A1
Press Solve

To put it all in VBA do the same as above while recording a macro and study
the recorded code.


RBS


"Jeffrey" wrote in message
...
Good day,

im just a newbie in VBA, i wonder if we can find X using VBA codes to
satisfy the equation below.

X^2 -28X+16 = 0.

Basically i want to find the value of X so that the left side of the
equation is equal to zero.

Thanks in advance.



Gary''s Student

Finding Values of X
 
Nearly the same as the equivalent worksheet formulas:

=(28+(28^2-4*16)^0.5)/2
=(28-(28^2-4*16)^0.5)/2

which yield:

27.41640786
0.583592135

--
Gary''s Student - gsnu200795


"Jeffrey" wrote:

Good day,

im just a newbie in VBA, i wonder if we can find X using VBA codes to
satisfy the equation below.

X^2 -28X+16 = 0.

Basically i want to find the value of X so that the left side of the
equation is equal to zero.

Thanks in advance.


JLGWhiz

Finding Values of X
 
Or you can use the Quadratic theory:

Sub uo()
x = -(-28) + Sqr((-28) ^ 2) - (4 * 1 * 16) / (2 * 1)
MsgBox x
x = -(-28) - Sqr((-28) ^ 2) - (4 * 1 * 16) / (2 * 1)
MsgBox x
End Sub


"Jeffrey" wrote:

Good day,

im just a newbie in VBA, i wonder if we can find X using VBA codes to
satisfy the equation below.

X^2 -28X+16 = 0.

Basically i want to find the value of X so that the left side of the
equation is equal to zero.

Thanks in advance.


JLGWhiz

Finding Values of X
 
Works better with all the parentheses in:

Sub uo()
x = -(-28) + Sqr(((-28) ^ 2) - (4 * 1 * 16)) / (2 * 1)
MsgBox x
x = -(-28) - Sqr(((-28) ^ 2) - (4 * 1 * 16)) / (2 * 1)
MsgBox x
End Sub


"Jeffrey" wrote:

Good day,

im just a newbie in VBA, i wonder if we can find X using VBA codes to
satisfy the equation below.

X^2 -28X+16 = 0.

Basically i want to find the value of X so that the left side of the
equation is equal to zero.

Thanks in advance.


Jeffrey[_2_]

Finding Values of X
 
On Jul 18, 10:43*am, Jeffrey wrote:
Good day,



Hi guys, thanks much for your response. they work. but have to
rephrase my question.
i should have ask this one at the first place.


r = W^2 + 4(H^2)
----------------------
8H

Values given are "r" and "W". And im looking for H.
I would like the user to enter the value of r and W in say a1 and a2
respectively, and the value of
H will be given.

Please advice. Thanks in advance.


Rick Rothstein \(MVP - VB\)[_2337_]

Finding Values of X
 
Yes, asking the question you actually want answered would seem to make more
sense. Anyway, solving for H yields these two equations.....

H1: =R1+SQRT(R1*R1-W1*W1/4)

H2: =R1-SQRT(R1*R1-W1*W1/4)

Where I picked cells who column address matched your variable letters.

Rick

"Jeffrey" wrote in message
...
On Jul 18, 10:43 am, Jeffrey wrote:
Good day,



Hi guys, thanks much for your response. they work. but have to
rephrase my question.
i should have ask this one at the first place.


r = W^2 + 4(H^2)
----------------------
8H

Values given are "r" and "W". And im looking for H.
I would like the user to enter the value of r and W in say a1 and a2
respectively, and the value of
H will be given.

Please advice. Thanks in advance.


Jeffrey[_2_]

Finding Values of X
 
Thanks a lot mate. This is such a relief.

Wish everyone a fantastic weekend.






On Jul 18, 12:44*pm, "Rick Rothstein \(MVP - VB\)"
wrote:
Yes, asking the question you actually want answered would seem to make more
sense. Anyway, solving for H yields these two equations.....

H1: * *=R1+SQRT(R1*R1-W1*W1/4)

H2: * *=R1-SQRT(R1*R1-W1*W1/4)

Where I picked cells who column address matched your variable letters.

Rick

"Jeffrey" wrote in message

...
On Jul 18, 10:43 am, Jeffrey wrote:

Good day,


Hi guys, thanks much for your response. they work. but have to
rephrase my question.
i should have ask this one at the first place.

r * *= * W^2 + 4(H^2)
* * * * ----------------------
* * * * * * * * 8H

Values given are "r" and "W". *And im looking for H.
I would like the user to enter the value of r and W in say a1 and a2
respectively, and the value of
H will be given.

Please advice. *Thanks in advance.



RB Smissaert

Finding Values of X
 
OK, I thought that you had worked out that the value couldn't simply be
simply calculated.
As you can no need for Solver. Still, it may come in handy one day.

RBS


"Jeffrey" wrote in message
...
Good day,

im just a newbie in VBA, i wonder if we can find X using VBA codes to
satisfy the equation below.

X^2 -28X+16 = 0.

Basically i want to find the value of X so that the left side of the
equation is equal to zero.

Thanks in advance.




All times are GMT +1. The time now is 01:21 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com