+ Reply to Thread
Results 1 to 5 of 5

VBA to lookup Position for region by approval amount

  1. #1
    Forum Contributor
    Join Date
    08-21-2008
    Location
    Hamilton, New Zealand
    MS-Off Ver
    Office 2007
    Posts
    255

    VBA to lookup Position for region by approval amount

    I require a bit of vba to do a match or lookup of 2 values to a matrix of delegated authority by region and return the Position ID.

    See sample data file attached.

    Lookup value 1 is the Region
    Lookup value 2 is the Amount

    The lookup Amount must not exceed the matching matrix amount, but must be the lowest matching Position ID.

    Assume that the matrix is sorted by Region, by Amount by Position ID.

    Eg.
    Region = A, Amount = 85,000 will return Position ID = Supervisor 1
    Region = C, Amount = 1,185,000 will return Position ID = General Manager 3
    Region = B, Amount = 500 will return Position ID = Admin 2

    Any help would be much appreciated. Thanks
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,527
    Hi there,

    Try this:

    Please Login or Register  to view this content.
    HTH

    Robert

  3. #3
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello wotadude,

    This doesn't require a VBA solution. The attach workbook has the following formula added to cell H2 (Result). The input cells are F2 and G2 (region and amount respectively).
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross
    Attached Files Attached Files

  4. #4
    Forum Contributor
    Join Date
    08-21-2008
    Location
    Hamilton, New Zealand
    MS-Off Ver
    Office 2007
    Posts
    255
    Both solutions proposed have pros and cons of what i wish to achieve.
    Thanks for your responses to date.

    The formula solution requires on going management of additional or named ranges.

    The VBA solution requires constant change to accomodate the change in the Matrix.

    I want the matrix to be the dynamic part (allowing for adding, changing or removing records as required) and the VBA to be the static part to return the result to a variable for futher use.

    If the VBA solution could match off the Region and returning the Position ID for the least Amount that the lookup amount it is less than or equal to. With the result passed to a variable.

  5. #5
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello wotadude,

    The workbook nows has a dynamic VBA macro. The only restrictions are that your table has no empty rows in it and that each region must have the same amounts. Here is the code that was added.

    Macro Code
    Please Login or Register  to view this content.
    Worksheeet Event Code
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross
    Attached Files Attached Files

+ 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. calculate fees from table
    By jcavigli in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 06-03-2008, 11:34 AM
  2. Matrix / multiple lookup / iteration challenge
    By MarkFranklin in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 03-19-2008, 06:45 AM
  3. Lookup function in a dynamic report
    By muchado77 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 08-28-2007, 12:27 AM
  4. Data filtering problem - challenging!
    By Cumberland in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 05-02-2007, 04:00 AM
  5. Lookup a value based on changes in another cell - Hard one
    By batyrjan in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-19-2007, 05:20 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