+ Reply to Thread
Results 1 to 8 of 8

Using Cells and Worksheets Functions in Formulas

  1. #1
    Registered User
    Join Date
    08-20-2014
    Location
    CLT
    MS-Off Ver
    2010
    Posts
    61

    Using Cells and Worksheets Functions in Formulas

    Good afternoon,

    I am wondering if it is possible to use the worksheets and cells functions within a formula as a cell location reference instead of a value. Please see below for what I currently have and ultimately what I would like to end up with to avoid any columns, worksheet name changes, or worksheets being added.

    Variable y are the number of columns in the original document. This forumla is going to be 2 columns to the right of the last column in the original document.

    Range(Cells(2, y + 2), Cells(x, y + 2)).Formula = "=INDEX('Cat. Table'!$C$2:$C$" & z & ",MATCH(N2,'Cat. Table'!$A$2:$A$" & z & ",0))"

    Is it possible to have the following as the N2 location may eventually change if new columns are added.

    Range(Cells(2, y + 2), Cells(x, y + 2)).Formula = "=INDEX('Worksheets(2)!$C$2:$C$" & z & ",MATCH(Cells(2,y+2),'Worksheets(2)'!$A$2:$A$" & z & ",0))"

    When I enter Cells(2,y+2) it returns the value in the previous cell; ultimately, I would like it to return the cell location, in this case N2.

    Thanks.
    Last edited by zmster2033; 10-03-2014 at 08:46 AM. Reason: Rename Thread

  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
    44,420

    Re: Formulas

    Untested, but try changing:

    Please Login or Register  to view this content.
    to:

    Please Login or Register  to view this content.

    Regards, TMS
    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
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,929

    Re: Formulas

    Please take a moment to read the forum rules and then amend your thread title to something descriptive of your problem (think google search terms?). Once you have done this please send me a PM and I will remove this request. (Also, include a link to your thread - copy from the address bar)

    Many members search our previous posts, and thread titles play a big part of the search. I doubt anybody would do a search based on your title?

    To change a Title on your post, click EDIT POST then Go Advanced and change your title, if 2 days have passed ask a moderator to do it for you.
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  4. #4
    Registered User
    Join Date
    08-20-2014
    Location
    CLT
    MS-Off Ver
    2010
    Posts
    61

    Using Cells and Worksheets Functions In Forumlas

    Updated thread name test.

  5. #5
    Registered User
    Join Date
    08-20-2014
    Location
    CLT
    MS-Off Ver
    2010
    Posts
    61

    Re: Using Cells and Worksheets Functions in Formulas

    Quote Originally Posted by TMS View Post
    Untested, but try changing:

    Please Login or Register  to view this content.
    to:

    Please Login or Register  to view this content.

    Regards, TMS
    TMS,

    Thanks for the response. The address piece underlined above is working correctly. Can you elaborate on what that is doing (sorry I am still a newbie). The Worksheets function is still not working correctly and is trying to open another file when the code reaches that statement. Any other suggestions? If I solve on my end, I will post the final outcome.

    Thanks.

  6. #6
    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
    44,420

    Re: Using Cells and Worksheets Functions in Formulas

    Try, untested:

    Please Login or Register  to view this content.

    Regards, TMS

  7. #7
    Registered User
    Join Date
    08-20-2014
    Location
    CLT
    MS-Off Ver
    2010
    Posts
    61

    Re: Using Cells and Worksheets Functions in Formulas

    Quote Originally Posted by TMS View Post
    Try, untested:

    Please Login or Register  to view this content.

    Regards, TMS

    This works splendidly! Thanks for your help. It is much appreciated!

  8. #8
    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
    44,420

    Re: Using Cells and Worksheets Functions in Formulas

    You're welcome. Thanks for the rep.



    If you are satisfied with the solution(s) provided, please mark your thread as Solved.


    New quick method:
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

    Or you can use this way:

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save


    You may also want to consider thanking those people who helped you by clicking on the little star at the bottom left of their reply to your question.

+ 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. Using Cell references in file paths for formulas to create dynamic formulas
    By MichaelStokesJr in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 12-04-2013, 11:49 AM
  2. Replies: 5
    Last Post: 09-25-2013, 02:51 PM
  3. Ctrl+Shift+Enter (CSE) array formulas in VBA using differing formulas
    By officeguy in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-11-2012, 04:31 PM
  4. Help modifying macro to wrap iferror formulas around existing formulas
    By dcgrove in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-14-2012, 02:04 PM
  5. Replies: 5
    Last Post: 05-05-2008, 02:22 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