+ Reply to Thread
Results 1 to 7 of 7

Longest string in a column

  1. #1
    Jeff Kantner
    Guest

    Longest string in a column

    Hi,
    I'm looking for the function combination to determine, in a column of text,
    what is the maximum number of characters in any one cell. max(len(cell))
    works for any one cell, but max(len(A:A)) manufactures a number from
    somewhere but whatever it is, it's not the number of characters in the
    longest cell. Perhaps an array function? But my attempt at that ended with
    #NUM!.

    Thx.

  2. #2
    Ron Coderre
    Guest

    RE: Longest string in a column

    You actually have the right idea:
    =MAX(LEN(A1:A10))

    Commit that array formula by holding down the [Ctrl]+[Shift] when you press
    [Enter]


    Does that help?

    ***********
    Regards,
    Ron


    "Jeff Kantner" wrote:

    > Hi,
    > I'm looking for the function combination to determine, in a column of text,
    > what is the maximum number of characters in any one cell. max(len(cell))
    > works for any one cell, but max(len(A:A)) manufactures a number from
    > somewhere but whatever it is, it's not the number of characters in the
    > longest cell. Perhaps an array function? But my attempt at that ended with
    > #NUM!.
    >
    > Thx.


  3. #3
    Biff
    Guest

    Re: Longest string in a column

    Hi!

    One way:

    Array entered using the key combo of CTRL,SHIFT,ENTER:

    =MAX(LEN(A1:A10))

    Biff

    "Jeff Kantner" <[email protected]> wrote in message
    news:[email protected]...
    > Hi,
    > I'm looking for the function combination to determine, in a column of
    > text,
    > what is the maximum number of characters in any one cell. max(len(cell))
    > works for any one cell, but max(len(A:A)) manufactures a number from
    > somewhere but whatever it is, it's not the number of characters in the
    > longest cell. Perhaps an array function? But my attempt at that ended with
    > #NUM!.
    >
    > Thx.




  4. #4
    Jeff Kantner
    Guest

    RE: Longest string in a column

    Thanks v much. I guess the limitation is the reference has to be an
    enumerated row range, not just A:A, e.g. I don't necessarily know the number
    of rows in the column, but since I'm looking for MAX, an arbitrarily long
    (high) number works, the empty cells at the bottom are < MAX so don't affect
    the result.

    "Ron Coderre" wrote:

    > You actually have the right idea:
    > =MAX(LEN(A1:A10))
    >
    > Commit that array formula by holding down the [Ctrl]+[Shift] when you press
    > [Enter]
    >
    >
    > Does that help?
    >
    > ***********
    > Regards,
    > Ron
    >
    >
    > "Jeff Kantner" wrote:
    >
    > > Hi,
    > > I'm looking for the function combination to determine, in a column of text,
    > > what is the maximum number of characters in any one cell. max(len(cell))
    > > works for any one cell, but max(len(A:A)) manufactures a number from
    > > somewhere but whatever it is, it's not the number of characters in the
    > > longest cell. Perhaps an array function? But my attempt at that ended with
    > > #NUM!.
    > >
    > > Thx.


  5. #5
    Ron Rosenfeld
    Guest

    Re: Longest string in a column

    On Wed, 30 Nov 2005 15:08:01 -0800, Jeff Kantner
    <[email protected]> wrote:

    >Hi,
    >I'm looking for the function combination to determine, in a column of text,
    >what is the maximum number of characters in any one cell. max(len(cell))
    >works for any one cell, but max(len(A:A)) manufactures a number from
    >somewhere but whatever it is, it's not the number of characters in the
    >longest cell. Perhaps an array function? But my attempt at that ended with
    >#NUM!.
    >
    >Thx.


    Yes you do need an array function. However, you cannot refer to an entire
    column in an array function.

    So the array-entered formula =MAX(LEN(A1:A65535)) should work.


    --ron

  6. #6
    Forum Contributor
    Join Date
    11-11-2005
    Posts
    267
    Clarification supplied:

    Supposing we have the following in a1:a5

    ColA
    ------
    CocaCola
    Alfafa
    Oats
    Strawberry
    Wheat

    How cam we adapt the array formula to deliver the longest text-in this instance Strawberry? Intuitively, I tried {=INDEX(A1:A8,MAX(LEN(A1:A10)),1)} but to no avail.
    Last edited by Myles; 12-01-2005 at 01:42 AM.

  7. #7
    Biff
    Guest

    Re: Longest string in a column

    Hi!

    Try this:

    Array entered:

    =INDEX(A1:A5,MATCH(MAX(LEN(A1:A5)),LEN(A1:A5),0))

    Biff

    "Myles" <[email protected]> wrote in
    message news:[email protected]...
    >
    > Supposing we have the following in a1:a5
    >
    > ColA
    > ------
    > CocaCola
    > Alfafa
    > Oats
    > Strawberry
    > Wheat
    >
    > How cam we adapt the array formula to deliver the *longest text*?
    > Intuitively, I tried *{=INDEX(A1:A8,MAX(LEN(A1:A10)),1)} *but to no
    > avail.
    >
    >
    > --
    > Myles
    > ------------------------------------------------------------------------
    > Myles's Profile:
    > http://www.excelforum.com/member.php...o&userid=28746
    > View this thread: http://www.excelforum.com/showthread...hreadid=489634
    >




+ 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