Closed Thread
Results 1 to 4 of 4

Quadratic Formula help in vba

  1. #1
    Registered User
    Join Date
    03-21-2014
    Location
    United States
    MS-Off Ver
    Excel 2003
    Posts
    15

    Quadratic Formula help in vba

    Hi Experts,

    I need some help to fix my Quadratic Equation in VBA. It looks fine except sqrt part.

    Here is the normal equation below X =

    -b +- √b^2-4(a)(c)
    ---------------------
    2(a)


    Here is my b value
    Moderator's note: Please take the time to review our rules. There aren't many, and they are all important. Rule #3 requires code tags. I have added them for you this time because you are a new member. --6StringJazzer
    Please Login or Register  to view this content.
    Based on B my equation looks like this


    Please Login or Register  to view this content.

    It would be great if someone can give an idea on sqrt part. Beside that all seems to be working.

    Thanks,
    Vik
    Last edited by 6StringJazzer; 04-09-2014 at 10:16 PM.

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Quadratic Formula help in vba

    You are on the right track. The main problem is that your parentheses are in the wrong place. But you have bigger problems than that so I'm going to make you start from scratch.

    I highly recommend that you declare variables a, b, and c. Then your formula is much more readable, and easier to set up and debug. It will look exactly like the quadratic formula, in code form.

    The quadratic formula gives two roots, but you have only calculated one of them. I am providing code to calculate both.

    Your assignment to b has a syntax error. Remove the initial left parenthesis.

    From context, it looks to me like c = ksp and a = 1. Never imply variables. If it's 1, then show a 1.

    Here is the best practice for coding this:

    Please Login or Register  to view this content.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,612

    Re: Quadratic Formula help in vba

    double post
    Ben Van Johnson

  4. #4
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Quadratic Formula help in vba

    Welcome to the Forum, unfortunately:

    This is a duplicate post and as such does not comply with Rule 5 of our forum rules. This thread will now be closed, you may continue in your other thread.

    Thread Closed.

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Quadratic Coefficients
    By Ian Adamson in forum Excel General
    Replies: 8
    Last Post: 05-07-2022, 10:06 AM
  2. Quadratic Equation in VBA
    By vop2311 in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 04-09-2014, 10:19 PM
  3. quadratic equations help needed
    By Joseph Little in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 01-08-2014, 10:25 AM
  4. Quadratic Regression - Help
    By kmr159 in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 04-08-2013, 08:26 AM
  5. Quadratic equation
    By Nes in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-11-2005, 10:52 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1