+ Reply to Thread
Results 1 to 8 of 8

solver [This iterative problem doesn't always work with Solver; can it be solved with VBA]

  1. #1
    Registered User
    Join Date
    08-09-2012
    Location
    Guelph, Ontario
    MS-Off Ver
    Excel 2007
    Posts
    9

    solver [This iterative problem doesn't always work with Solver; can it be solved with VBA]

    I am doing repetitive calculations in excel on about 150 rows of data; the data is pressure measured over time. the equation i solve is:

    h=w+(transducer depth+w)*w''/9.81

    w is water level change which is WL1-WL2; WL1 is given

    I match the solution with the data I collected, h using solver to change WL2 until the solution matches my measured data. sometimes solver doesn't work and returns a large number for WL2; then I manually change it until it matches. this is very time consuming and inefficient. is there a way to program in VB to accomplish this with or without solver? attached is an example file. i have a ton of files to dothanks
    Attached Files Attached Files

  2. #2
    Forum Expert Kenneth Hobson's Avatar
    Join Date
    02-05-2007
    Location
    Tecumseh, OK
    MS-Off Ver
    Office 365, Win10Home
    Posts
    2,573

    Re: solver [This iterative problem doesn't always work with Solver; can it be solved with

    I don't know how to solve for row 2. For others, here is how to do it.

    I note threads where I participate. As such, I see that you cross-posted this and it had no response either.

    e.g. For row 3:
    Please Login or Register  to view this content.

  3. #3
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,829

    Re: solver [This iterative problem doesn't always work with Solver; can it be solved with

    If my first impression is correct, h is a quadratic function of WL2 (h=a*WL2^2+b*WL2+c). With a little algebra, I would expect you to be able to arrange the equation in that form, then you can use the quadratic formula (much to the joy of our algebra teachers, to whom we swore we would never use the quadratic formula in real life) to find the two roots for WL2 and decide which one is the correct "real" value for the problem at hand. With the correct use of relative and absolute references, you should only need to enter these formulas into Excel once, then copy them down. An approach like this will eliminate the need to use Solver and the potential for Solver's numeric algorithms to diverge like that.

    If you need a quick refresher on the quadratic formula: http://www.purplemath.com/modules/quadform.htm
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  4. #4
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2402
    Posts
    13,448

    Re: solver [This iterative problem doesn't always work with Solver; can it be solved with

    Your post does not comply with Rule 8 of our Forum RULES. Do not crosspost your question on multiple forums without including links here to the other threads on other forums.

    Cross-posting is when you post the same question in other forums on the web. The last thing you want to do is waste people's time working on an issue you have already resolved elsewhere. We prefer that you not cross-post at all, but if you do (and it's unlikely to go unnoticed), you MUST provide a link (copy the url from the address bar in your browser) to the cross-post.

    Expect cross-posted questions without a link to be closed and a message will be posted by the moderator explaining why. We are here to help so help us to help you!

    Read this to understand why we ask you to do this, and then please edit your first post to include links to any and all cross-posts in any other forums (not just this site).

  5. #5
    Registered User
    Join Date
    08-09-2012
    Location
    Guelph, Ontario
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: solver [This iterative problem doesn't always work with Solver; can it be solved with

    Thanks! and sorry, i had no idea about cross posting. i wont do it again....

  6. #6
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,829

    Re: solver [This iterative problem doesn't always work with Solver; can it be solved with

    We are not against cross-posting, just cross-posting without links. Without those links, those of us who only frequent this site (or who first encounter the question on this site) do not know if the problem has been resolved elsewhere or not. Cross-post as much as you want, but provide the links to the other forums where you have posted the question, so we can see what progress (if any) is being made on all sites before jumping into the discussion.

  7. #7
    Forum Expert Kenneth Hobson's Avatar
    Join Date
    02-05-2007
    Location
    Tecumseh, OK
    MS-Off Ver
    Office 365, Win10Home
    Posts
    2,573

    Re: solver [This iterative problem doesn't always work with Solver; can it be solved with

    MrShorty, there is no square term so it is not a quadratic equation.

    The only way that I know to solve row 2 is to copy the formula from row 3. Doing that, does change all the w and WL values. I think that is the right way to go though.

    Please Login or Register  to view this content.

  8. #8
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,829

    Re: solver [This iterative problem doesn't always work with Solver; can it be solved with

    MrShorty, there is no square term so it is not a quadratic equation.
    When you multiply w by the second derivative (w''), you will end up with a w^2 term (among others). If I followed the algebra correctly:

    wi''=wi'-w(i-1)'
    wi'=wi-w(i-1)
    w3''=w3'-w2'=w3-w2-(w2-w1)=w3-2w2+w1
    w3*w3''=w3^2-2*w2*w3+w1*w3

    Plug that back into the original formula and work through the rest of the algebra, and you should end up with something like h=a*w3^2+b*w3+c, then solve the quadratic.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Using Solver With Another Iterative Routine
    By kubota1000 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-03-2023, 12:37 AM
  2. [SOLVED] Excel SOLVER problem, claims it is solved but retains original values. Example given.
    By ad9051 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 05-25-2012, 04:18 PM
  3. Optimization problem when Solver doesn't work
    By fouzi in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-24-2012, 09:53 AM
  4. Interesting Solver problem (Solver encounters an error)
    By MrShorty in forum Excel General
    Replies: 3
    Last Post: 12-22-2005, 06:55 PM
  5. Problem getting solver to work in macro
    By dlowie in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-26-2005, 02:05 PM
  6. [SOLVED] How can the Travelling Salesman Problem be solved using Solver Ad.
    By andrei665 in forum Excel General
    Replies: 3
    Last Post: 04-16-2005, 12:07 AM
  7. Excel Solver with Macro doesn't work
    By Jukka in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-10-2005, 01:06 PM

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