Consulting

Results 1 to 8 of 8

Thread: Length of text within cells

  1. #1
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location

    Length of text within cells

    Is there a method of calculationg the length of a string of text in relation to a cell?
    My workbook setup does not allow me to autofit rows, as it would upset printer output. I would like then, having typed in a string of text, that the length is split into suitable lengths, additional rows inserted to suit, and the text written in the appropriate cells.
    I've done this before based on a set number of characters, looking for the previous space and so on, which works tolerably well, but is not very flexible. Any suggestions for a better approach?
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  2. #2
    Site Admin
    Urban Myth
    VBAX Guru
    Joined
    May 2004
    Location
    Oregon, United States
    Posts
    4,940
    Location
    MD,

    The closest I think one can come to that would be expressed by Suat's recent entry to Aaron Blood's Challenge ... http://www.xl-logic.com/xl_files/cha..._detection.zip

    Other than that, I'm not sure that there's a decent way to do this. Maybe checking pixel length using API..??

  3. #3
    Administrator
    VP-Knowledge Base VBAX Master
    Joined
    Jan 2005
    Location
    Porto Alegre - RS - Brasil
    Posts
    1,219
    Location
    Hi MD,

    maybe you could use this:


    Range("A1:IV65536").WrapText = True
    Best Regards,

    Carlos Paleo.

    To every problem there is a solution, even if I dont know it, so this posting is provided "AS IS" with no warranties.

    If Debugging is harder than writing a program and your code is as good as you can possibly make
    it, then by definition you're not smart enough to debug it.




    http://www.mugrs.org

  4. #4
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Hi Carlos,
    I have to insert a footer/header every 45 rows when the document is printed with "Carry Forwards" etc, page numbering etc. If I wrap text, I'll need to start finding page lengths etc, which is a route I wish to avoid.
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  5. #5
    Administrator
    VP-Knowledge Base VBAX Master
    Joined
    Jan 2005
    Location
    Porto Alegre - RS - Brasil
    Posts
    1,219
    Location
    Oh ok, well than the only thing I can imagine is to follow Zacks suggestion.
    Best Regards,

    Carlos Paleo.

    To every problem there is a solution, even if I dont know it, so this posting is provided "AS IS" with no warranties.

    If Debugging is harder than writing a program and your code is as good as you can possibly make
    it, then by definition you're not smart enough to debug it.




    http://www.mugrs.org

  6. #6
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Thanks Zack,

    I've had a look at that, but it doesn't look like the way forward, but here's my solution to Aaron's problem (I've done a KB with it too)

    Zip file revised; options added.
    Last edited by Zack Barresse; 03-25-2005 at 12:59 PM. Reason: Removed attachment as per request

  7. #7
    Administrator
    VP-Knowledge Base VBAX Master
    Joined
    Jan 2005
    Location
    Porto Alegre - RS - Brasil
    Posts
    1,219
    Location
    Great Malcolm,


    I will save it, who knows when I may need it.
    Best Regards,

    Carlos Paleo.

    To every problem there is a solution, even if I dont know it, so this posting is provided "AS IS" with no warranties.

    If Debugging is harder than writing a program and your code is as good as you can possibly make
    it, then by definition you're not smart enough to debug it.




    http://www.mugrs.org

  8. #8
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Update

Posting Permissions

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