+ Reply to Thread
Results 1 to 15 of 15

Thread: Creating a Cell That References a Value That Changes When Data is Filtered?

  1. #1
    Registered User
    Join Date
    12-06-2011
    Location
    Durham, NC
    MS-Off Ver
    Excel 2010
    Posts
    11

    Creating a Cell That References a Value That Changes When Data is Filtered?

    Hoping someone out there can help me with a problem I am having. I have two columns of data, as shown below...

    A | B
    -----------
    1| X | 10
    2| X | 20
    3| X | 30
    4| Y | 40
    5| Y | 50
    6| Y | 60

    I apply an auto filter on column A. In another cell I want to reference the first value in column B for whatever category in column A I have filtered. So if I have filtered only for value X, I want this cell to bring back the value 10. If I have filtered only for value Y, I want this cell to bring back the value 40.

    So is there a way to have a cell who's value changes dynamically when an auto filter is changed?

    Many thanks for any help you can provide.
    Last edited by guyute76; 12-09-2011 at 09:16 AM.

  2. #2
    Registered User
    Join Date
    12-06-2011
    Location
    Durham, NC
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: Creating a Cell That References a Value That Changes When Data is Filtered?

    I have attached a file for further clarification of my problem. Above is a bit of a simplification, and I may be asking the wrong question here. The attached worksheet has a graph based on the data to the left. I set it up to look like a timeline of the dates provided in the data. I have applied a filter to the data so that I can choose to look at different categories ("Work Holidays" or "Birthdays" in this case) and the graph will update based on the data that is currently showing in the filter. The problem I'm running into is with the labels I've applied to the data points in the graph. When the data is filtered to show only the "Birthdays" category, the data points on the graph are correct, but the labels still show the "Work Holidays" value. How can I create this graph so the data labels update dynamically with the rest of the graph? It would also be nice if I could get the Chart Title to update based upon which category is selected in the filter, Seems like this is the same issue and if we can solve the labels issue, we can solve the title issue with the same method.

    Timeline.xls

    Can anyone help me?

  3. #3
    Valued Forum Contributor Haseeb A's Avatar
    Join Date
    05-24-2011
    Location
    India | Kwt
    MS-Off Ver
    2007
    Posts
    1,453

    Re: Creating a Cell That References a Value That Changes When Data is Filtered?

    Try this Array formula, confirmed with CTRL+SHIFT+ENTER, rather than just ENTER.

    =INDEX(C2:C20,MATCH(1,SUBTOTAL(3,OFFSET(C2,ROW(C2:C20)-ROW(C2),)),0))
    HTH; Haseeb

    If your problem is solved, please say so clearly, and mark your thread as Solved:
    Forum Rules & How to Mark a thread as SOLVED

  4. #4
    Forum Guru Whizbang's Avatar
    Join Date
    08-05-2009
    Location
    Greenville, NH
    MS-Off Ver
    Excel 2010
    Posts
    1,249

    Re: Creating a Cell That References a Value That Changes When Data is Filtered?

    Assuming that Column A will always be sorted in ascending order:

    =INDEX(C2:C7,SUBTOTAL(5,A2:A7))

  5. #5
    Registered User
    Join Date
    12-06-2011
    Location
    Durham, NC
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: Creating a Cell That References a Value That Changes When Data is Filtered?

    Haseeb A & Whizbang, I'm hoping you can give me a little more context to your replies. Looks like you're both doing something similar, but I'm unclear as to what data your formulas are refering to, is this in reference to the sample data in my first post, or the data I provided in the attachment file in the second post? The data ranges you each use in your formulas are confusing me.

    Thank you both.

  6. #6
    Valued Forum Contributor Haseeb A's Avatar
    Join Date
    05-24-2011
    Location
    India | Kwt
    MS-Off Ver
    2007
    Posts
    1,453

    Re: Creating a Cell That References a Value That Changes When Data is Filtered?

    The link you posted is not working. Since forum been allowed to attach files attach your sample on the forum instead of a link. Go to,

    Go Advanced >> Manage attachments, & browse your file.
    HTH; Haseeb

    If your problem is solved, please say so clearly, and mark your thread as Solved:
    Forum Rules & How to Mark a thread as SOLVED

  7. #7
    Valued Forum Contributor Haseeb A's Avatar
    Join Date
    05-24-2011
    Location
    India | Kwt
    MS-Off Ver
    2007
    Posts
    1,453

    Re: Creating a Cell That References a Value That Changes When Data is Filtered?

    Deleted...Multiple post...Sorry about that
    Last edited by Haseeb A; 12-06-2011 at 02:53 PM. Reason: Multiple post
    HTH; Haseeb

    If your problem is solved, please say so clearly, and mark your thread as Solved:
    Forum Rules & How to Mark a thread as SOLVED

  8. #8
    Registered User
    Join Date
    12-06-2011
    Location
    Durham, NC
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: Creating a Cell That References a Value That Changes When Data is Filtered?

    Retry at attachment...
    Attached Files Attached Files

  9. #9
    Forum Guru Whizbang's Avatar
    Join Date
    08-05-2009
    Location
    Greenville, NH
    MS-Off Ver
    Excel 2010
    Posts
    1,249

    Re: Creating a Cell That References a Value That Changes When Data is Filtered?

    My formula is in reference to your data as per your original post.
    Quote Originally Posted by guyute76
    A | B
    -----------
    1| X | 10
    2| X | 20
    3| X | 30
    4| Y | 40
    5| Y | 50
    6| Y | 60
    Although my formula assumes that row 1 has header information.

  10. #10
    Registered User
    Join Date
    12-06-2011
    Location
    Durham, NC
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: Creating a Cell That References a Value That Changes When Data is Filtered?

    Quote Originally Posted by Whizbang View Post
    My formula is in reference to your data as per your original post.


    Although my formula assumes that row 1 has header information.
    Thanks Whizbang. Your formula works great. Now what if I wanted to create a second cell that returns the second value in each category after filtering? So in my example...

    A| B | C
    -----------
    1| X | 10
    2| X | 20
    3| X | 30
    4| Y | 40
    5| Y | 50
    6| Y | 60

    ... now I want to return value 20 when filtered for X and value 50 when filtered for Y.
    Last edited by guyute76; 12-07-2011 at 01:57 PM.

  11. #11
    Registered User
    Join Date
    12-06-2011
    Location
    Durham, NC
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: Creating a Cell That References a Value That Changes When Data is Filtered?

    Bump with edit to my last post. Still trying to solve this one. Can anyone help me extrapolate Whizbang's original formula to give me the second value for each subgroup as explained in the post above?

  12. #12
    Forum Guru Whizbang's Avatar
    Join Date
    08-05-2009
    Location
    Greenville, NH
    MS-Off Ver
    Excel 2010
    Posts
    1,249

    Re: Creating a Cell That References a Value That Changes When Data is Filtered?

    Haseeb A's answer was much more on track than my simple solution. It ensures that the first value will be returned, no matter the sort.

    Here is Haseeb A's formula, modified to account for returning multiple results.

    =INDEX(C2:C20,SMALL(IF(SUBTOTAL(3,OFFSET(C2,ROW(C2:C20)-ROW(C2),))=1,ROW($C$1:$C$19)),ROW(1:1)))
    This is confirms with CTRL+SHIFT+ENTER

    Then copy down the number of row that you desire.

  13. #13
    Registered User
    Join Date
    12-06-2011
    Location
    Durham, NC
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: Creating a Cell That References a Value That Changes When Data is Filtered?

    Quote Originally Posted by Whizbang View Post
    Haseeb A's answer was much more on track than my simple solution. It ensures that the first value will be returned, no matter the sort.

    Here is Haseeb A's formula, modified to account for returning multiple results.

    =INDEX(C2:C20,SMALL(IF(SUBTOTAL(3,OFFSET(C2,ROW(C2:C20)-ROW(C2),))=1,ROW($C$1:$C$19)),ROW(1:1)))
    This is confirms with CTRL+SHIFT+ENTER

    Then copy down the number of row that you desire.
    OK, this is great, you guys are really on to it here. Can I ask one more favor, and sorry to be a pain, but this formula is way over my head. Instead of saying "copy down the number of row that you desire", can you spell out exactly what this formula would look like if I wanted to return the second data value from each category? I think if I saw that, it would help me understand the formula better.

    I can't thank you all enough, great forum here.

  14. #14
    Valued Forum Contributor Haseeb A's Avatar
    Join Date
    05-24-2011
    Location
    India | Kwt
    MS-Off Ver
    2007
    Posts
    1,453

    Re: Creating a Cell That References a Value That Changes When Data is Filtered?

    Quote Originally Posted by guyute76 View Post
    I think if I saw that, it would help me understand the formula better
    Can you please attach your dummy file, where is actually your data starts and where/what do you want to return? Attachment on post#2 is not valid.
    HTH; Haseeb

    If your problem is solved, please say so clearly, and mark your thread as Solved:
    Forum Rules & How to Mark a thread as SOLVED

  15. #15
    Forum Guru Whizbang's Avatar
    Join Date
    08-05-2009
    Location
    Greenville, NH
    MS-Off Ver
    Excel 2010
    Posts
    1,249

    Re: Creating a Cell That References a Value That Changes When Data is Filtered?

    A small correction on the formula:

    =INDEX($C$2:$C$20,SMALL(IF(SUBTOTAL(3,OFFSET(C2,ROW($C$2:$C$20)-ROW(C2),))=1,ROW($C$1:$C$19)),ROW(1:1)))


    Copied down one cell, it would be:
    =INDEX($C$2:$C$20,SMALL(IF(SUBTOTAL(3,OFFSET(C3,ROW($C$2:$C$20)-ROW(C3),))=1,ROW($C$1:$C$19)),ROW(2:2)))

    But you don't need to manually adjust the formula. Simply select the first cell and Copy it. Then select the desired number of cells below and then Paste. The formula will automatically adjust. That is the beauty of cell referencing. It can be fixed using the $ symbol, or relative by omiting the $. Do a Google search on cell referencing and read up on Relative, Fixed and Mixed references.

    You can also take advantage of the AutoFill function. Do a search on that for more information.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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.2.0