+ Reply to Thread
Results 1 to 3 of 3

Finding the value of a variable through iteration

  1. #1
    Registered User
    Join Date
    01-08-2014
    Location
    Richmond, Virginia
    MS-Off Ver
    Excel 2003
    Posts
    2

    Finding the value of a variable through iteration

    Hello,

    I have a workbook that I use regularly at my office, and on this workbook there is a certain variable that I'll call x. Currently the only way to find the value x is through a trial and error method in which I equate two different functions of x, f1(x) and f2(x), and plug in values for x until the two sides are equal, or y = f1(x)-f2(x)>=0 (or close enough.) I am trying to automate this process. I want to create a macro that starts with a value based on a known variable z, x0 = z+180 to be exact, and iterates the x value until y is as small as possible but > 0. Today has been my first exposure to VBA programming, and the few attempts I've made so far have gotten me caught up in infinite loops. Does anybody have an idea of how to do this, or any ideas for alternative ways to achieve the same goal? Thanks for any help!

  2. #2
    Forum Contributor gsnidow's Avatar
    Join Date
    07-22-2010
    Location
    Richmond, VA
    MS-Off Ver
    Excel 2007
    Posts
    150

    Re: Finding the value of a variable through iteration

    Have you thought about using solver? That is what it is for. You can use it in VBA, provided a reference to it is loaded.
    Just a guy trying to make work stuff easier.

  3. #3
    Registered User
    Join Date
    01-08-2014
    Location
    Richmond, Virginia
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re: Finding the value of a variable through iteration

    I didn't know there was such a thing as a solver, but after looking it up I think it could be the way to go. To think, before today I thought I was pretty proficient in Excel, haha. Thanks gsnidow

+ 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. Finding a value in a table where both row and column are variable
    By jungx006 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 04-07-2013, 09:27 AM
  2. Replies: 4
    Last Post: 02-18-2012, 11:47 AM
  3. Finding if a variable is equal to a number set
    By finndus in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-06-2011, 05:29 PM
  4. Finding a Variable Value with in multiple ranges
    By mikejohn11 in forum Excel General
    Replies: 3
    Last Post: 10-05-2010, 01:12 AM
  5. finding a variable
    By vassili in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-20-2007, 04:08 AM

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