+ Reply to Thread
Results 1 to 2 of 2

User-defined function to compare value to a table and display corresponding value

  1. #1
    Registered User
    Join Date
    04-23-2013
    Location
    Houston
    MS-Off Ver
    Excel 2010
    Posts
    2

    User-defined function to compare value to a table and display corresponding value

    Hello, All. When I couldn't figure out how to get excel to do the things I wanted in a cell, I wrote a macro in VBA, which I'm sure is full of problems, but, with no previous experience in VBA and only programming experience in Fortran 77- haha- I am unable to diagnose the issues. I am grateful to anyone who can take a look see. It could very well be that I don't need a macro for the formula. If I do, what's wrong with mine?

    I will describe the issue in terms of a single cell, since I believe it makes the objective more clear, and since one working cell will get them all working. I want G3 to compare E3's value to the values of the I-column rows and return the corresponding J-column value of the I-column value closest to that of E3. (You'll notice in my macro that I crudely simplified the program to return the higher of the J-column values of the I-column values that E3 lies between, which is fine, too).

    The table (the I and J columns) was copy+pasted into the spreadsheet, which might be part of the problem.

    The reason I want G3 to be formulated/programmed is so that B and C columns can be user-edited at any time. Obviously, looking up five values on a table on the same page is not the issue. I would like to be able to have many rows of values, if I wanted, making an auto-instant-evaluation-and-answer quite a useful tool, as well as the general engineering brain that just won't let me have a moment's peace until I solve this problem.
    Attached Files Attached Files

  2. #2
    Registered User
    Join Date
    04-23-2013
    Location
    Houston
    MS-Off Ver
    Excel 2010
    Posts
    2

    Re: User-defined function to compare value to a table and display corresponding value

    ps The formula in G3 now was just a test for a simple IF statement-- please ignore. Press alt+F11 to look at macro. It is under Modules in the tree. Thank you!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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