+ Reply to Thread
Results 1 to 11 of 11

Passing a worksheet name and cell address, and retreive the value of the worksheet's cell

  1. #1
    Forum Contributor
    Join Date
    02-01-2019
    Location
    Illinois
    MS-Off Ver
    2016
    Posts
    223

    Passing a worksheet name and cell address, and retreive the value of the worksheet's cell

    I am trying to create a very small function that accepts a parameter inputs the name of a worksheet and the address of a cell.
    The function's objective is to go to the worksheet and return the integer value of the cell.

    I've tried many variants on the following code:
    Please Login or Register  to view this content.
    I know there has to be a solution. This is too useful a funtion to not have a way to make it work.

    Thank you for your help!

  2. #2
    Forum Expert wk9128's Avatar
    Join Date
    08-15-2020
    Location
    Australia
    MS-Off Ver
    365 V2403 and WPS V2022
    Posts
    3,422

    Re: Passing a worksheet name and cell address, and retreive the value of the worksheet's c

    Pls try this code

    Please Login or Register  to view this content.

  3. #3
    Forum Expert
    Join Date
    08-17-2007
    Location
    Poland
    Posts
    2,223

    Re: Passing a worksheet name and cell address, and retreive the value of the worksheet's c

    What problem do you have with this function, since it seems to be written fairly correctly?

    Artik

  4. #4
    Forum Contributor
    Join Date
    02-01-2019
    Location
    Illinois
    MS-Off Ver
    2016
    Posts
    223

    Re:

    My bad. I thought this example was so simple that I didn't need to follow protocol by posting the file. I can see that I was wrong and apologize.

    You will see my problem if you open the attached file, go do the 'Repeating Risks' worksheet and look at C21. You will find the function there and it evaluates to #VALUE!.
    Instead, I want the function to return the value of C7 from the worksheet 'Remove Identical'.
    Attached Files Attached Files
    Last edited by lovecolorado; 03-25-2024 at 10:03 AM.

  5. #5
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,913

    Re: Passing a worksheet name and cell address, and retreive the value of the worksheet's c

    C7 doesn't have a cell address in it. If you want the value from C7 on the other sheet, then you should use "C7" in the formula, not C7. Also, I don't know why you wouldn't just use INDIRECT. Also, since you cannot pass a worksheet object from a cell (you're just passing the name), it needs to be:

    Please Login or Register  to view this content.
    Last edited by rorya; 03-25-2024 at 10:24 AM.
    Rory

  6. #6
    Forum Contributor
    Join Date
    10-02-2012
    Location
    UK
    MS-Off Ver
    Office 365
    Posts
    252

    Re: Passing a worksheet name and cell address, and retreive the value of the worksheet's c

    I'm still trying to understand the purpose of the function. How is this better than directly referencing the cell?.

    Please Login or Register  to view this content.
    Would surely return the same as

    Please Login or Register  to view this content.
    Or am I missing something?

  7. #7
    Forum Contributor
    Join Date
    02-01-2019
    Location
    Illinois
    MS-Off Ver
    2016
    Posts
    223

    Re: Passing a worksheet name and cell address, and retreive the value of the worksheet's c

    Yeah . . . you're missing a lot. I apologize for not knowing how to explain this more succintly, but you did ask . . . so here goes.

    I've developed a method to show whether the benefit or risk of a healthcare process is greater. Fortunately, my process avoids the problems inherent in representing risk or benefit by numbers. I represent one risk with one ordered pair of strings of text, where the two parts of the ordered pair are text strings that describe the probability of a risk occurring and the severity of a risk occurring. I then represent the overall risk by the set of all of the individual risks. And, I've worked out four operations that can be used to simplify two sets of risks (one set representing the patient's risk before the healthcare proces and one set representing the risk after the healthcare process) until it is intuitively clear which risk is greater.

    Even though what I've developed is a significant improvement over existing methods (most of whom fail right out of the gate because they use numbers to represent risk), a whole lot of people are going to freak out about the prospect of simplifying an equation with two sets whose elements are ordered pairs of text. To demystfy this process, I've created a worksheet that implements each of the four operations. I'm hoping this will make clear to people that each operation is logical and intuitively correct.

    Once people get comfortable with having a spreadsheet perform one simplification operaion, I plan to copy one of the four spreadsheets to performs a simplificaiton operation. And I plan to repeat this 10 to 50 worksheets in order to simplify an initially quite complex equation of risks until one set is empty and the other is not. The empty set will have the lower risk.

    The difficulty is that the order of operations will change when the two sets of risks change. So, I need a way of applying operations in whatever order people want, using tools that most people who are familiar with Excel can do. This requirment knocks out doing this in VBA, but most people can create and copy worksheets.



    I can finally answer your question:
    These worksheets will have formulas in them and each worksheet will get its input from the last, previous worksheet. The cells in the worksheet copies will never change, but the cells that each new worksheet will always reference cells from the last previous worksheet.
    The point of this function is to enable me to enter, in just one place in a new worksheet, the name of the previous worksheet and have all of the formulas in the new worksheet point to the last previous worksheet instead of whichever worksheet it used to point to. There could be 150 references to a previous worksheet, so doing this by hand is out of the question. i need a function that looks at a single cell for the worksheet name that all of its cells should point to and updates all of the formulas with this worksheet name.

    As for why didn't I use the 'indirect' command: Perhaps I should have. I'm only slightly familiar with that command. Attached is the file containing my latest attempts, including with the indirect command.
    Attached Files Attached Files
    Last edited by lovecolorado; 03-25-2024 at 03:48 PM.

  8. #8
    Forum Contributor
    Join Date
    02-01-2019
    Location
    Illinois
    MS-Off Ver
    2016
    Posts
    223

    Re: Passing a worksheet name and cell address, and retreive the value of the worksheet's c

    First, I apologize for thinking that this issue was so simple that i didn't need to post the file I'm using. I was wrong and you couldn't see that your suggestion didn't work.

    If you would please check out the attached file, the function you wrote has been named Cell_Value10 and is in cell F4, along with another half-dozen attempts to make this work. I would greatly appreciate your hellp. Thank you.
    Attached Files Attached Files

  9. #9
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,913

    Re: Passing a worksheet name and cell address, and retreive the value of the worksheet's c

    Again, if D7 is the cell you want the value from, you need to pass its address "D7", not to pass it as a reference (which will mean you are passing the contents of D7 - i.e. 1. Also that code is nothing like the code I posted.

    In any event, all you need is:

    =INDIRECT("'"&F2&"'!D7")

    No code required.

  10. #10
    Forum Contributor
    Join Date
    02-01-2019
    Location
    Illinois
    MS-Off Ver
    2016
    Posts
    223

    Re: Passing a worksheet name and cell address, and retreive the value of the worksheet's c

    Thank you all for your persistance.
    Because of the target audience, I was trying to avoid the use of helper cells, but, because I can't get the INDIRECT command or anything else to to work inside a function, I'll need 70 helper cells per worksheet.
    I've been stuck long enough so I'll bite the bullet and just create a block of hidden helper cells off to the side.
    Last edited by lovecolorado; 03-26-2024 at 07:38 AM.

  11. #11
    Forum Expert wk9128's Avatar
    Join Date
    08-15-2020
    Location
    Australia
    MS-Off Ver
    365 V2403 and WPS V2022
    Posts
    3,422

    Re: Passing a worksheet name and cell address, and retreive the value of the worksheet's c

    @lovecolorado You're Welcome. Glad to help . Thank You for the feedback and rep.

+ 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] Fetch cell content given worksheet name and cell address
    By CDandVinyl in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-01-2020, 09:34 PM
  2. [SOLVED] vba excel - passing table subtotal value to worksheet cell
    By terriertrip in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-03-2017, 01:48 AM
  3. [SOLVED] finding cell address from another worksheet
    By shaunfish in forum Excel General
    Replies: 9
    Last Post: 08-05-2014, 06:19 AM
  4. Replies: 9
    Last Post: 09-13-2013, 04:37 AM
  5. Passing a cell/worksheet/workbook in a macro
    By vbace2 in forum Excel General
    Replies: 2
    Last Post: 11-08-2006, 10:16 AM
  6. Cell Address:in a worksheet
    By Zambrosio in forum Excel General
    Replies: 1
    Last Post: 02-23-2006, 11:30 AM
  7. Copy Worksheet Tab Name into a cell address
    By Andy in forum Excel General
    Replies: 2
    Last Post: 04-06-2005, 12:06 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