+ Reply to Thread
Results 1 to 6 of 6

New "WHATIF" scenario macro / function

  1. #1
    Registered User
    Join Date
    10-26-2010
    Location
    Switzerland
    MS-Off Ver
    Excel 2003
    Posts
    7

    New "WHATIF" scenario macro / function

    Hi,

    I would like to create a macro to define a new Excel function as follows:

    =WHATIF(output_ref, input_ref, input_value)

    The function would calculate the result of a given output cell on changing a specific input cell to an alternative value, for example:

    A1 = 10
    A2 = 20
    A3 = A1+A2 = 30
    A4 = WHATIF(A3,A1,5) = 25

    In other words, the "WHATIF" function would calculate the result of the formula in output_cell in the scenario where input_cell is changed to input_value.

    Does anybody know if this function already exists, or can anybody suggest suitable VBA code to define it?

    Unfortunately none of the built-in tools (goal seek, data tables, scenarios, etc.) do the job because I would like to copy this "WHATIF" formula (with and/or without $ anchors) over a large array of cells.

    Any help would be very much appreciated, thanks!

    Kind regards,
    Kelvin

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,131

    Re: New "WHATIF" scenario macro / function

    I think that's probably Tools | Goal Seek...

    Regards
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    10-26-2010
    Location
    Switzerland
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: New "WHATIF" scenario macro / function

    Quote Originally Posted by TMShucks View Post
    I think that's probably Tools | Goal Seek...
    Thanks, but I looked at that. I need to define an explicit function that I can write in a cell and copy, but goalseek is a tool, not a function. Also, goalseek determines the input for a given output, but I need to determine the output for a given input (without changing the value in the input cell).
    Last edited by Kelvin Stott; 10-26-2010 at 12:21 PM.

  4. #4
    Registered User
    Join Date
    10-26-2010
    Location
    Switzerland
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: New "WHATIF" scenario macro / function

    Never mind, I just received the answer in another forum:

    http://www.mrexcel.com/forum/showthread.php?p=2489271

    ;-)

  5. #5
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,974

    Re: New "WHATIF" scenario macro / function

    I suggest you read the rules before posting again. If you cross-post, you must post links to the other posts. (the same is true of most forums incidentally)
    Everyone who confuses correlation and causation ends up dead.

  6. #6
    Registered User
    Join Date
    10-26-2010
    Location
    Switzerland
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: New "WHATIF" scenario macro / function

    I apologize, sorry. Looking back I agree it wasn't good etiquette, I'll review the rules more carefully (EDIT: done :-).

    Regarding the problem, it seems the solution didn't quite work as intended, so the issue remains open, in need of a solution...

    Sorry again for the cross-post.
    Last edited by Kelvin Stott; 10-26-2010 at 05:18 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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