+ Reply to Thread
Results 1 to 7 of 7

Count no. of lines of text in a text wrapped cell

  1. #1
    Registered User
    Join Date
    07-27-2018
    Location
    Newcastle
    MS-Off Ver
    2013
    Posts
    20

    Count no. of lines of text in a text wrapped cell

    Hi All,

    I am trying to get the count of the number of lines of text in a cell that has text wrap applied to it. To clarify the text has no manual returns, but the cell may be a page wide and has maybe 3-6 lines of text where excel has moved text to new lines in order to keep within the column.

    I've tried the following formula:

    =LEN(B4)-LEN(SUBSTITUTE(B4,CHAR(10),""))+1

    But as there are no actual keyed returns, the result is always 1.

    Any ideas? I'm trying to ascertain the value so that I can use it to set the row height more accurately than autofit, which is so inconsistent.

    Thanks

    mjmitch

  2. #2
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2406
    Posts
    44,662

    Re: Count no. of lines of text in a text wrapped cell

    You'd done the hard bit...

    =IF(B4="",0,LEN(B4)-LEN(SUBSTITUTE(B4,CHAR(10),""))+1)
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU

  3. #3
    Registered User
    Join Date
    07-27-2018
    Location
    Newcastle
    MS-Off Ver
    2013
    Posts
    20

    Re: Count no. of lines of text in a text wrapped cell

    Cheers Glenn,

    See attached file. How do I get the result in D4 to be 5?

    Len Formula.xlsx

  4. #4
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2406
    Posts
    44,662

    Re: Count no. of lines of text in a text wrapped cell

    You can't. Your text NOT split into separate lines using CHAR-10. It is merely wrapped in a narrow column. Test 1 is separated from test 2, etc, by a space, not by CHAR-10.

  5. #5
    Registered User
    Join Date
    07-27-2018
    Location
    Newcastle
    MS-Off Ver
    2013
    Posts
    20

    [SOLVED] Count no. of lines of text in a text wrapped cell

    Thanks All

  6. #6
    Forum Contributor
    Join Date
    04-30-2015
    Location
    The Netherlands
    MS-Off Ver
    office 365
    Posts
    195

    Re: Count no. of lines of text in a text wrapped cell

    Did you manage to get the VBA to work?

    https://www.excelforum.com/excel-for...turns-1-a.html <-- other thread that was closed.
    Last edited by FerdyHar; 09-27-2018 at 08:21 AM. Reason: added link to other post
    Remember to mark as Solved and give out rep.

  7. #7
    Registered User
    Join Date
    07-27-2018
    Location
    Newcastle
    MS-Off Ver
    2013
    Posts
    20

    Re: Count no. of lines of text in a text wrapped cell

    No, but the thread was closed by admin. It works but just wasn't sure if that was the most efficient way to code it to run through a large number of cells

    Please Login or Register  to view this content.

+ 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. Replies: 9
    Last Post: 07-24-2015, 12:40 PM
  2. [SOLVED] Split Wrapped Text (Multiple Lines) in A Cell to Multiple Columns
    By csmiin in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 08-28-2012, 09:15 PM
  3. RE: Autofit in cells with multiple lines of wrapped text.
    By John Keith in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-02-2006, 11:35 AM
  4. How can I get excel to show ALL lines of wrapped text?
    By bmg in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 12-27-2005, 01:45 PM
  5. [SOLVED] How to adjust spacing between lines of wrapped text ?
    By SUZL in forum Excel General
    Replies: 1
    Last Post: 12-15-2005, 07:55 PM
  6. number of lines of wrapped text
    By Fred in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-19-2005, 09:06 AM
  7. Replies: 3
    Last Post: 03-19-2005, 04:34 AM

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