Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default 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.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default 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.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default 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.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default 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.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default 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.



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default 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.

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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.

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default 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.


  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default 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.


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Finding Most Recent Values in Col1 -- Summing Matching Values Rothman Excel Discussion (Misc queries) 5 December 20th 07 08:19 PM
finding values italiavb Excel Programming 3 March 18th 06 12:59 AM
Finding values within text and substituting with alternate values. Bhupinder Rayat Excel Programming 3 January 24th 06 01:44 PM
Finding values funkymonkUK[_81_] Excel Programming 2 November 23rd 05 03:29 PM
finding values and displaying adjacent values willy3211 Excel Worksheet Functions 1 October 12th 05 04:49 PM


All times are GMT +1. The time now is 03:36 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"