+ Reply to Thread
Results 1 to 13 of 13

formula doesn't work in name

  1. #1
    Forum Expert
    Join Date
    03-31-2009
    Location
    Barstow, Ca
    MS-Off Ver
    Excel 2002 & 2007
    Posts
    2,164

    formula doesn't work in name

    I have 2 names:
    Please Login or Register  to view this content.
    that work fine, but when I combine them into 1 name:
    Please Login or Register  to view this content.
    it doesn't work.

    Why?
    Last edited by foxguy; 09-29-2011 at 08:42 AM.
    Foxguy

    Remember to mark your questions [Solved] and rate the answer(s)
    Forum Rules are Here

  2. #2
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: formula doesn't work in name

    Doesn't work in what way?
    Remember what the dormouse said
    Feed your head

  3. #3
    Forum Expert
    Join Date
    03-31-2009
    Location
    Barstow, Ca
    MS-Off Ver
    Excel 2002 & 2007
    Posts
    2,164

    Re: formula doesn't work in name

    When it's 2 names "=myCount" returns 9, but when it's 1 name "=myCount" returns 1.

  4. #4
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: formula doesn't work in name

    I see what you mean. Looks like a bug to me. It will work if you use:
    =COUNTA(INDEX(OFFSET(L!$C$7,2,0,ROWS(L!A:A)-ROW(L!$C$7)-1,1),0))

  5. #5
    Forum Expert
    Join Date
    03-31-2009
    Location
    Barstow, Ca
    MS-Off Ver
    Excel 2002 & 2007
    Posts
    2,164

    Re: formula doesn't work in name

    RS;
    Yeah, but that's what I'm trying to get away from. Offset() is volatile, Index() isn't.
    Teylyn and I have been working to try and get rid of Offset(), but haven't been successful. Oh well.

  6. #6
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: formula doesn't work in name

    I don't understand - your original version contains OFFSET and nowhere have you mentioned trying to remove that.

  7. #7
    Forum Expert
    Join Date
    03-31-2009
    Location
    Barstow, Ca
    MS-Off Ver
    Excel 2002 & 2007
    Posts
    2,164

    Re: formula doesn't work in name

    RS;
    Sorry got 2 different threads confused. My last message doesn't apply to your answer. I'll try your suggestion.

  8. #8
    Forum Expert
    Join Date
    03-31-2009
    Location
    Barstow, Ca
    MS-Off Ver
    Excel 2002 & 2007
    Posts
    2,164

    Re: formula doesn't work in name

    RS;
    It worked fine. Thanks

  9. #9
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: formula doesn't work in name

    Glad to help.

    Now please comply with your signature, and mark the thread solved.

  10. #10
    Forum Expert
    Join Date
    03-31-2009
    Location
    Barstow, Ca
    MS-Off Ver
    Excel 2002 & 2007
    Posts
    2,164

    Re: formula doesn't work in name

    That makes twice that I forgot to mark a thread solved. I must be losing it.

  11. #11
    Forum Expert Colin Legg's Avatar
    Join Date
    03-30-2008
    Location
    UK
    MS-Off Ver
    365
    Posts
    1,256

    Re: formula doesn't work in name

    It looks like the problem is being caused by the ROW() function, combined with the context of the formula (being in a name, plus the other functions in the name). If you test the formula using a constant (say 7), instead of ROW(L!$C$7) then it returns the correct result.


    In the formula with the COUNTA, ROW(L!$C$7) returns an array type (ie. {7}).

    Assuming the worksheet has 65536 rows, ROWS(L!B:B)-ROW(L!$C$7)-1 returns {65528}.


    Now, if I do a little testing in VBA:

    v1 and v2 are identical, the array type Height argument makes no difference.
    But v3 and v4 are different -
    Please Login or Register  to view this content.
    Hope that helps,

    Colin

    RAD Excel Blog

  12. #12
    Forum Expert
    Join Date
    03-31-2009
    Location
    Barstow, Ca
    MS-Off Ver
    Excel 2002 & 2007
    Posts
    2,164

    Re: formula doesn't work in name

    Colin;
    Now the question is: is that a bug or by design? Is there any reason to expect Row($C$7) to return an array when combined with CountA()? Especially since it works as expected when the formula is put in a cell.

  13. #13
    Forum Expert Colin Legg's Avatar
    Join Date
    03-30-2008
    Location
    UK
    MS-Off Ver
    365
    Posts
    1,256

    Re: formula doesn't work in name

    Hi,

    I'll just clarify one point:
    COUNTA() itself isn't causing ROW(C7) to return an array type. It's the name context; when the formula is entered straight into a cell, =ROW(C7) returns 7, not {7}.

    If you look at v1 and v2 in my VBA test, you can see that this "feature" doesn't cause a problem. But when you introduce COUNTA(), an aggregator function, it does cause a problem.

    I'm honestly not certain why it's doing it, and I'd rather not speculate because I'll probably be wrong!



    Although the analysis doesn't give us the ultimate inner nuts and bolts, it does give us enough understanding to suggest other workarounds. We know that the array type is causing the problem, so if we convert the array type to a double like this: {65528} ----> 65528 then we know that the formula will be okay. How to convert {65525} to 65528? Well, SUM() will do it.

    examples -

    Please Login or Register  to view this content.

    Please Login or Register  to view this content.

    Not a solution that would have been immediately obvious, but is quite neat.
    Last edited by Colin Legg; 09-29-2011 at 11:28 AM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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