Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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. |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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. |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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. |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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. |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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. |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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. |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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. |
#8
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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. |
#9
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Finding Most Recent Values in Col1 -- Summing Matching Values | Excel Discussion (Misc queries) | |||
finding values | Excel Programming | |||
Finding values within text and substituting with alternate values. | Excel Programming | |||
Finding values | Excel Programming | |||
finding values and displaying adjacent values | Excel Worksheet Functions |