Results 1 to 10 of 542

Thread: Appendix Thread. App Index Rws() Clms() Majic code line Codings for other Threads, Tables etc.)

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #4
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    10,457
    Rep Power
    10

    Alternative Codes using [ ] shorthand

    Using LOOKUP to get the last value

    For the particular formula that I am trying to get to and understand, ( one of this sort of form =LOOKUP(2;1/(C:C<>"");C:C) ) ,I need to look a bit further into the behaviour of LOOKUP, in particular the second argument.

    A few observations:
    _observation
    VLOOKUP seems to assume that the list/ range of numbers is in ascending order
    For example, this sort of thing,
    1
    3
    4
    2
    Row\Col E
    37 1
    38 3
    39 4
    40 2
    41
    42

    , with the LOOKUP formula of these sort of things
    =LOOKUP(5;E37:E40)
    =LOOKUP(5;{1;3;4;2})

    , will return 2. In fact it always seems to return the last value. This initially points us into perhaps a direction of thinking to just look for any number likely to be bigger than any in the list of numbers (in the second argument range)

    _observation
    Extend the range a bit , to example include some empty cells,
    =LOOKUP(5;E37:E43)
    , and once again the answer is 2.
    This is very interesting and helpful. It seems not to error when not getting numbers, (as I was thinking that the second argument would be always expecting numbers). The empty cells simply seem to be ignored

    But at this point some alarm bells are ringing in my head. The final solution forms I am envisaging, are likely to involve array type things, so I want to continue as I have done so far, to consider the array alternative, and I am getting worried now – because…
    depending on your viewpoint, an empty cell can be regarded and one if at least 3 things I know about
    ___ Empty
    ___ 0
    ___ a zero length string, often represented by ""

    Well, I can’t be too sure about how to distinguish all 3 in a formula, but I can do a partial job by considering these two array formula versions
    =LOOKUP(5;{3;4;2;0;0;0}) ' returns 0
    =LOOKUP(5;{3;4;2;"";"";""}) ' returns 2


    The difference in those two results is enough for me to ponder about for a while. But I don’t need tom ponder too long.
    It makes sense where we get 0, since 0 is a number, and in line with what we have already said
    _____ VLOOKUP takes the very last number in a list if it never finds either the number it is looking for , or if it never finds a larger number at any other position in a list, (in this latter case it would take the number before that bigger number)
    For the purposes of the array type formula, "" , can be regarded, (with some caution perhaps), of behaving like our spreadsheet empty cell. We will come back to this last point, but let’s give a pictorial summary so far of where we are

    Row\Col E F
    37 1 =LOOKUP(5,E37:E40)
    38 3 =LOOKUP(5,{1;3;4;2})
    39 4 =LOOKUP(5,E37:E43)
    40 2 =LOOKUP(5,{3;4;2;0;0;0})
    41 =LOOKUP(5,{3;4;2;"";"";""})
    42
    43

    Row\Col E F
    37 1 2
    38 3 2
    39 4 2
    40 2 0
    41 2
    42
    43





    In Excel functions and formulas generally, the difference between using a number and a text can be significant. The fact that the array version both accepts ( does not error with ) the "" , and gives us perhaps a useful answer , the last number, could be useful….

    Also it may be worth checking what happens if the text is not zero length.
    Here we go, lets try filling the empty cells with some text:
    Row\Col E F
    37 1 =LOOKUP(5,E37:E41)
    38 3 =LOOKUP(5,{1;3;4;2})
    39 4 =LOOKUP(5,E37:E43)
    40 2 =LOOKUP(5,{1;3;4;2;0;0;0})
    41 a =LOOKUP(5,{1;3;4;2;"a";"b";"c"})
    42 b
    43 c

    Row\Col E F
    37 1 2
    38 3 2
    39 4 2
    40 2 0
    41 a 2
    42 b
    43 c

    Hmm…. So it seems to treat an actual text just like the zero length text



    In the next post we will develop/ explain a solution
    Last edited by DocAElstein; 09-10-2025 at 12:36 AM.

Similar Threads

  1. Replies: 192
    Last Post: 08-30-2025, 01:34 AM
  2. Replies: 3
    Last Post: 03-07-2022, 05:12 AM
  3. HTML (Again!) arrOut()=Index(arrIn(),Rws(),Clms()
    By DocAElstein in forum Test Area
    Replies: 1
    Last Post: 08-23-2014, 02:27 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •