+ Reply to Thread
Results 1 to 6 of 6

Use CELL function for SheetName in formula to retrieve data

  1. #1
    Forum Contributor
    Join Date
    06-08-2012
    Location
    Panama City, FL
    MS-Off Ver
    Excel 2016
    Posts
    175

    Use CELL function for SheetName in formula to retrieve data

    Hello friends,
    I'd appreciate help completing this formula. It will permit me to use the same formula for multiple sheets without editing.
    Please see attached example. Instead of typing CVL in the first line I'd like to use the formula {which works alone} to 'find' the SheetName and use in place of each CVL.
    Thanks!

    # =COUNTIF(CVL!CVL_RASS_,"<>")
    # =MID(CELL("filename",A1),FIND("]",CELL("filename",A1))+1,3)
    Attached Files Attached Files

  2. #2
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 V 2506
    Posts
    13,792

    Re: Use CELL function for SheetName in formula to retrieve data

    Your post shows COUNTIF. The upload shows SUMIF. I went with SUMIF in C6.
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Does this do what you want?
    Dave

  3. #3
    Forum Contributor
    Join Date
    06-08-2012
    Location
    Panama City, FL
    MS-Off Ver
    Excel 2016
    Posts
    175

    Re: Use CELL function for SheetName in formula to retrieve data

    Thanks Dave! Yes that works for the first part of the problem. I accidentally used SUMIF/COUNTIF, but it doesn't matter, just working to learn how to write a formula. What you have done is the perfect start, but two problems remain.

    The first of the two remaining problems is that only the first CVL was dealt with.
    The second CVL near the end still needs to use the CELL function, otherwise, when I use this formula with the sheetName XYZ it won't work because it'd be looking for the NamedRange CVL_RASS_ instead of NamedRange XYZ_RASS_. I see it'll be pretty hairy because the whole thing for the second CVL will fall outside of the closing single quote but inside of the closing double quote. WOW!

    The second and major remaining problem is that I'm not actually trying to get you to write this for me, it's only a test.
    Since I'm obviously not smart enough to figure out how to do this, I'm really seeking to LEARN HOW to do this and to UNDERSTAND IT so I can do this kind of thing in the future. I'm hoping you can share an explanation with me simple enough for my feeble mind to GET IT. I'm just baffled about how you 'knew' to put the !CVL_RASS_ inside of the double quotes. I think I understand that the beginning and ending single quotes encompass everything on the sheetName side of the !.

    What I'm seeing, (right or wrong), is that you put double quotes around the opening single quote (to make it literal TEXT?) AND you put double quotes around the closing single quote (to also make that quote literal TEXT?) BUT have included the remote sheetName range within the second set of double quotes. I'm guessing that is because the entire Indirect function needs to be inside of the quotes???
    ...or is the double quote in front of each single quote just an escape character???

    Continued help from You or Anyone out there is Greatly appreciated.
    Last edited by GregM56; 09-12-2018 at 12:03 AM. Reason: Adding an additional thought

  4. #4
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 V 2506
    Posts
    13,792

    Re: Use CELL function for SheetName in formula to retrieve data

    The single quotes are required for the sheet name(s) as well as the !. Wrapping the CVL_RASS_ inside the quotes was an educated guess derived from the fact that is how literal cell ranges are treated. Indirect syntax often confuses me. I don't use it very often in cross sheet references so I resort to trial and error. I managed to get this one right the first time.

    Having said that I will do what I can to work with you on the rest of this. It will take me time and I will need another upload that reflects what you mean by XYZ and XYZ_RASS_ ... and others. I need to see the layout(s) in context of the workbook. I am not the best "go to guy" for this function, and building these strings dynamically may prove to be a challenge.

    Yes INDIRECT takes literal text. In order to address other sheets and ranges you have to build your reference strings. You've got the basic idea of how to use MID/CELL/FIND to extract the desired strings. So that much is solved. We'll muddle through the rest if necessary, but truth be known we may already have the solutions.

    Let me know.

  5. #5
    Forum Expert azumi's Avatar
    Join Date
    12-10-2012
    Location
    YK, Indonesia
    MS-Off Ver
    Excel 365
    Posts
    2,406

    Re: Use CELL function for SheetName in formula to retrieve data

    Perhaps, hope this works, and if not just @Dave said, try to explain in a simple way about your desired results

    =SUMPRODUCT(SUMIF(INDIRECT("'"&$C$4&"'!B1:B100"),"<>",INDIRECT("'"&$C$4&"'!B1:B100")))
    Last edited by azumi; 09-13-2018 at 01:47 AM.

  6. #6
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 V 2506
    Posts
    13,792

    Re: Use CELL function for SheetName in formula to retrieve data

    Good point azumi. Never occurred to me to just extend the ranges.

+ 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] Copy paste data based on cell value to sheetname
    By kannan1847 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-15-2015, 07:03 AM
  2. [SOLVED] Retrieve Data From Cell Based in Array Based on LARGE Function
    By justarandomguy in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 10-13-2014, 02:31 AM
  3. [SOLVED] Cell = sheetname get values from sheetname
    By soli004 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-29-2014, 10:00 AM
  4. Replies: 15
    Last Post: 08-24-2013, 10:05 AM
  5. Using Sheetname in Vlookup as the sheetname for the array to lookup
    By OhioHsSport in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 06-05-2013, 09:18 PM
  6. Retrieve data from a cell on another workbook using concatenate function
    By Tom_Fe in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 02-05-2013, 07:55 AM
  7. SheetName Function
    By EXCEL$B!!(BNEWS in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 04-17-2006, 03:10 AM

Tags for this Thread

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