+ Reply to Thread
Results 1 to 5 of 5

Reference one cell in proximity to another

Hybrid View

  1. #1
    Registered User
    Join Date
    10-06-2008
    Location
    Boston
    Posts
    3

    Reference one cell in proximity to another

    Hi everyone,

    I attempted to search the forums for this question, but didn't have any luck. This is kind of difficult to explain, but I'll give it a shot. Is there any way to refer to one cell that is X number of spaces above, below, or to the left or right of another cell in a formula?

    I want a VLOOKUP formula to grab the value of one cell and then subtract the value of the cell directly above the first cell. In the example below, cell V7 will be changing every time I update the workbook:

    example:
    =VLOOKUP($V$7,$A$2:$L$25,2,0)
    Suppose that the VLOOKUP returned the value from cell B20, I'd want the next part of the formula to subtract the value of cell B19. Please let me know if you need any clarification. I'd appreciate any help. Thanks in advance!
    Last edited by fadeoutagain278; 10-07-2008 at 08:31 AM.

  2. #2
    Registered User
    Join Date
    10-06-2008
    Location
    Boston
    Posts
    3
    [bumping topic]

    This is work-related, so I'm hoping someone will have an answer!

  3. #3
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582
    Hi Fadeout,
    With these types of offsets, best to work with INDEX and MATCH instead of VLOOKUPs (IMHO). The formula would be (based on the info you gave)
    =INDEX($A$2:$L$25,MATCH($V$7,$A$2,0),2)-INDEX($A$2:$L$25,MATCH($V$7,$A$2,0)-1,2)
    Does this work for you?
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  4. #4
    Valued Forum Contributor
    Join Date
    08-26-2008
    Location
    singapore
    Posts
    626
    I think this is what you need.


    
    =IF(INDIRECT("r"&(ROW()-1)&"c"&COLUMN(),0)=0,0,VLOOKUP($V$7,$A$2:$L$25,2,0)-INDIRECT("r"&(ROW()-1)&"c"&COLUMN(),0))
    I need your support to add reputations if my solution works.


  5. #5
    Registered User
    Join Date
    10-06-2008
    Location
    Boston
    Posts
    3
    ChemistB, that code did the trick! I just needed to change the MATCH function you provided to include $A$2:$A$25 as the array instead of just $A$2. I'm not too familiar with INDEX, so I appreciate the assistance, I think I understand how it works now. This is really going to clean up my formulas. Thanks again!

    sglife, thanks go to you also, I'll see if that will work for me too.

+ 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. [SOLVED] Variable Cell Reference
    By Tyr@work in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 02-28-2014, 01:23 AM
  2. VBA to rename worksheet based on cell reference on another worksheet
    By Sandi99 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-20-2008, 01:46 PM
  3. Reference cell between worksheets
    By markjoyus in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 12-04-2007, 12:31 PM
  4. Conditional Formatting - Reference another cell
    By MitchU in forum Excel General
    Replies: 1
    Last Post: 11-21-2007, 05:41 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