+ Reply to Thread
Results 1 to 11 of 11

Using the contents of a cell as a cell reference in a formula

  1. #1
    Registered User
    Join Date
    01-29-2018
    Location
    London, England
    MS-Off Ver
    2013
    Posts
    7

    Unhappy Using the contents of a cell as a cell reference in a formula

    This is going to seem really contrived so I really hope I can explain this well. I have thousands of nearly identical templates which I need to put into a single worksheet. When they're identical I've managed to work this out, and that's fine. There are a few hundred, however, which have an number of rows added at one point of the template (but the number of rows is different for each one). I worked out how to, for each template, work out how many rows have been added so now the only question is adding an amount to the cell reference of each subsequent cell by an amount equal to the number of rows added.

    I managed to do this, and now the current situation I have is that on one sheet (Sheet19) I have cells filled with the cell references I need to refer to in a given template sheet (TEMPLATE SHEET). The sheet I'm filling in we will call Main Sheet

    Sheet 19 right now looks like this:

    NameofTEMPLATE SHEET D2 D4 D6 .... etc

    So in Main Sheet I have a formula which reads the name of TEMPLATESHEET from Sheet19 then reads a given cell in that sheet. The formula I have used is: (as an example) =INDIRECT("'"&Sheet19!A2&"'!D40")

    With the new rows, however, I need to change that D40 to the cell in Sheet19. I tried this but it did not work: =INDIRECT("'"&Sheet19!A2&"'!INDIRECT("'"&Sheet19!$A$1&"'!D2")") (where in A1 I have inserted "Sheet19" The idea of this formula is to look in Sheet 19, cell A2, which has the name of the template, then to search in Sheet19 for the name Sheet19 (convoluted), then within that search for the cell D2 in Sheet19 which contains a cell reference which I need).

    Convoluted right? Absurdly poorly explained...

    Honestly I would just upload the sheet so you guys can see but I'm not allowed unfortunately. Really appreciate any help though...

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Using the contents of a cell as a cell reference in a formula

    Perhaps.

    =INDIRECT("'"&Sheet19!A2&"'!"&INDIRECT("'"&Sheet19!$A$1&"'!D2"))
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    01-29-2018
    Location
    London, England
    MS-Off Ver
    2013
    Posts
    7

    Re: Using the contents of a cell as a cell reference in a formula

    ...correct in less than 5 minutes.

    That was amazing. Thank you!

  4. #4
    Registered User
    Join Date
    01-29-2018
    Location
    London, England
    MS-Off Ver
    2013
    Posts
    7

    Re: Using the contents of a cell as a cell reference in a formula

    Quick follow up question. I want to be able to scroll downwards a good few thousand times so that the second formula is: =INDIRECT("'"&Sheet19!A3&"'!"&INDIRECT("'"&Sheet19!$A$1&"'!D3")) and the third formula is =INDIRECT("'"&Sheet19!A4&"'!"&INDIRECT("'"&Sheet19!$A$1&"'!D4")) etc.

    When I'm scrolling down only the A is changing - any way to make both of them change?

  5. #5
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Using the contents of a cell as a cell reference in a formula

    Which range are you putting the formula in?

  6. #6
    Registered User
    Join Date
    01-29-2018
    Location
    London, England
    MS-Off Ver
    2013
    Posts
    7

    Re: Using the contents of a cell as a cell reference in a formula

    Range? The first reference is in N6, and I'd like to pull it down to N1000 and something. I'm going to replicate the same formula (modified slightly) for each of O to AT...

  7. #7
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Using the contents of a cell as a cell reference in a formula

    Perhaps something like this then?

    =INDIRECT("'"&Sheet19!A4&"'!"&INDIRECT("'"&Sheet19!$A$1&"'!D" & ROW()-2))

  8. #8
    Registered User
    Join Date
    01-29-2018
    Location
    London, England
    MS-Off Ver
    2013
    Posts
    7

    Re: Using the contents of a cell as a cell reference in a formula

    I suspect that approach is very close to the right line, but it's not quite working. As far as I can tell with that it's taking A4 along with D2 and A5 with D3 etc.

    If I remove the -2 would it keep the 4s with the 4s and 5s with the 5s etc?

  9. #9
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,005

    Re: Using the contents of a cell as a cell reference in a formula

    Try this:

    =INDIRECT("'"&Sheet19!A3&"'!"&INDIRECT("'"&Sheet19!$A$1&"'!"&CELL("address",D3)))
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU.

    Temporary addition of accented to illustrate ongoing problem to the TT: L? fh?ile P?draig sona dhaoibh

  10. #10
    Registered User
    Join Date
    01-29-2018
    Location
    London, England
    MS-Off Ver
    2013
    Posts
    7

    Re: Using the contents of a cell as a cell reference in a formula

    Solved! You both are absolutely brilliant - thank you very much!

  11. #11
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,005

    Re: Using the contents of a cell as a cell reference in a formula

    You're welcome.



    If that takes care of your original question, please select "Thread Tools" from the menu link above and mark this thread as SOLVED.

    It'd also be appreciated if you were to click the Add Reputation button at the foot of any of the posts of all members who helped you reach a solution.

+ 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. Replies: 5
    Last Post: 06-01-2015, 03:38 PM
  2. [SOLVED] Insert Cell Contents using Cell Reference - =SMALL(IF
    By DarrylBurge in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-22-2014, 05:30 AM
  3. Replace Cell Reference with Cell Contents
    By londos in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-04-2011, 11:08 AM
  4. VLOOKUP to return Cell reference rather than Cell Contents.
    By Wozza147 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 07-22-2009, 07:49 AM
  5. [SOLVED] Getting contents of a cell when cell reference is in the sheet
    By A Nelson in forum Excel General
    Replies: 3
    Last Post: 10-05-2005, 02:05 PM
  6. [SOLVED] Cell only shows link in text, not contents of reference cell
    By Jay Mac in forum Excel - New Users/Basics
    Replies: 4
    Last Post: 08-23-2005, 04:05 PM
  7. Using MATCH result in Cell Reference to replace cell contents
    By Rolls100 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 02-02-2005, 05:56 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