Need to write a GoalSeek function in C#

Posted on 2004-10-27
Last Modified: 2007-12-19

I am in the process of moving over an Excel spreasheet with macros in it to a web application.  All is well, except for this one cell which contains within it a GOALSEEK function. I have no idea what the algorithm is to replicate this function, or if I can import some DLL to simply access it... Help!

Thanks in advance,


Range("E31").GoalSeek Goal:=0, ChangingCell:=Range("D31")
Question by:anoukmercier
    LVL 8

    Accepted Solution

    The Goalseek function takes an input parameter and a target ouput, and will change a variable so that using a specific mathematical aloghritm, the target output is reached, and will return the value of the changing variable. (what a lousy sentence :)

    If you'll always do the same mathematical aloghritm, for example finding the correct rate for a monthly payment, you might want to write that function yourself? Depending on how complex it is, it might be easier then importing Excel functions (I have no idea how that works).



    Author Comment

    You're right... I was hoping for some sort of magic formula, I guess, but I finally rolled up my sleeves to try and figure out what the heck was happening in the background, and once I figured out what that function did, I was able to replicate some code (had to create a while loop to iterate through the target value, and re-calculate all functions).


    LVL 8

    Expert Comment

    Glad you figured it out :)

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Suggested Solutions

    Title # Comments Views Activity
    Inheritance in C# 3 56
    C# Linq Update XML 5 25
    Line meaning 9 44 mvc 3 24
    In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
    Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
    This video Micro Tutorial is the first in a two-part series that shows how to create and use custom scanning profiles in Nuance's PaperPort 14.5 ( But the ability to create custom scanning profiles al…
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    931 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now