+ Reply to Thread
Results 1 to 3 of 3

Truncate string based on width of characters used

  1. #1
    Registered User
    Join Date
    02-02-2015
    Location
    Portland
    MS-Off Ver
    2013
    Posts
    32

    Truncate string based on width of characters used

    Hey all,

    I was wondering if anybody had an idea on how to easily truncate a string based on the width of characters used (not the number of characters used). For example, after the text of a cell reaches a length of 350 pixels, replace the last 3 characters used with "...", and stop adding more. This won't work by using len() as character width varies as such - ::::: vs WWWWW

    The only way I could think of doing this was to manually generate a dictionary of possible characters and assign each a value based on their respective pixel widths. Then, get a sum of the pixel width, and truncate appropriately. However, this seems like a fairly blunt approach to the goal. Any ideas?

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Truncate string based on width of characters used

    Is this in a cell or a textbox?

    Why not use a fixed-pitch font?
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Registered User
    Join Date
    02-02-2015
    Location
    Portland
    MS-Off Ver
    2013
    Posts
    32

    Re: Truncate string based on width of characters used

    This would be in a cell.

    Honestly was not aware of fixed-pitch fonts before this moment... I'll look into the mono-spaced fonts excel provides, but I'm fairly picky when it comes to font styles. To provide context in this particular instance, the sheet in question is a report that will contain titles of bugs from a database which can be fairly lengthy from time-to-time. I want to ensure that titles wider than a certain pixel value get truncated as it makes everything easier when I shift the report from Excel to Outlook.

+ 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. [SOLVED] truncate a string x characters after a delimiter
    By timmatthews in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-19-2013, 05:56 PM
  2. Truncate text in a cell after so many words or characters
    By theblade24 in forum Excel General
    Replies: 9
    Last Post: 06-07-2013, 01:29 PM
  3. How to Truncate first 80 characters by keeping meaningful word in end
    By Rens243 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 04-02-2013, 04:17 AM
  4. Truncate a string
    By Xx7 in forum Excel General
    Replies: 5
    Last Post: 04-04-2011, 06:07 PM
  5. Replies: 3
    Last Post: 09-09-2010, 10:41 AM
  6. Truncate all characters left of 6th character
    By fredmeister in forum Excel General
    Replies: 3
    Last Post: 02-09-2010, 04:41 PM
  7. Replies: 4
    Last Post: 01-13-2006, 09:55 AM
  8. fill or truncate to a certain number of characters in a cell
    By Jan Buckley in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 03-16-2005, 12:06 PM

Tags for this Thread

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