+ Reply to Thread
Results 1 to 10 of 10

Formatting literally text

  1. #1
    Registered User
    Join Date
    10-07-2015
    Location
    Belgium
    MS-Off Ver
    2010
    Posts
    5

    Formatting literally text

    Hi,

    I want to format literally the text (so not numbers, dates, currency).

    Basically I want the value 1.3.13 to be 1.03.013; so add a 0 to the place I want in the text.

    I.e. SUBSTITUTE will not work for me all the time as I have different values like below, and it's also possible that I don't want a 0 after all dots:
    - 1.09.13 should be 1.09.013
    - 4.2.1 should be 4.02.001
    - 4.3.448 should be 4.03.448

    I do not want to do things like, i.e find the first and second dots, then look for the length of the string in between, if it's 2 add one 0 on the left.

    Can I make a custom Format Cells "formula", or i.e. some formatting with TEXT to achieve this?

    Thanks and best regards,

    Meibrah

  2. #2
    Forum Expert
    Join Date
    03-23-2004
    Location
    London, England
    MS-Off Ver
    Excel 2019
    Posts
    7,064

    Re: Formatting literally text

    "I want the value ... to be ..."

    Custom formatting will NOT change the value, only the format, ie the way it appears on screen.
    Regards
    Special-K

    Ensure you describe your problem clearly, I have little time available to solve these problems and do not appreciate numerous changes to them.

  3. #3
    Registered User
    Join Date
    10-07-2015
    Location
    Belgium
    MS-Off Ver
    2010
    Posts
    5

    Re: Formatting literally text

    Indeed you're correct Special-K. My wrong choice of words.

    Let me rephrase:

    I want the 1.3.13 to appear as 1.03.013; so add a 0 to the place I want in the text.
    Can I make a custom Format Cells "formula", or i.e. some formatting with TEXT to achieve this?

    Thanks and best regards,

    Meibrah
    Last edited by meibrah; 10-07-2015 at 09:38 AM.

  4. #4
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,829

    Re: Formatting literally text

    I think I would do a "text to columns" ("." as the delimiter) to separate the three numbers into separate cells. Then a simple =CONCATENATE() and TEXT() combination should be able to recombine the text string. Something like =CONCATENATE(A2,".",TEXT(B2,"00"),".",text(C2,"000")).
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  5. #5
    Registered User
    Join Date
    10-07-2015
    Location
    Belgium
    MS-Off Ver
    2010
    Posts
    5

    Re: Formatting literally text

    Thanks MrShorty.

    This indeed works if all info is in different columns.

    Would there be a direct way to format it from one column as you can for a datetime/number/currency value?

    Best regards,

    Meibrah

  6. #6
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,829

    Re: Formatting literally text

    I'm not sure what you mean by "a direct way". IMO, using the Text to Colummns command to separate the text string into its parts, then rejoining with CONCATENATE() is a pretty direct way to perform the task.

    Perhaps by "direct way" you prefer something that uses only excel's worksheet functions. I am not proficient with Excel's text manipulation functions (https://support.office.com/en-us/art...__toc309306717 there should be a similar help file in your Excel installation, especially if you prefer to use the help file in a language other than English), but I expect it would look something like:

    1) Use the FIND() function to locate the position of the "." characters in the original text string.
    2) Use the LEFT(), MID(), and/or RIGHT() functions to extract the parts of the text string.
    3) The VALUE() function may be needed to convert "numbers as text" to numbers before inputting into the TEXT() function.
    4) Then, use the CONCATENATE() and TEXT() functions as I described above to recombine the text strings as desired.

    In essence, we are replacing the single Text to columns command with a combination of worksheet functions.

    And, this becomes more difficult if you insist on performing all of those operations in a single cell mega formula, which I never do.

    In terms of "divide and conquer" which parts of this do you need help with?

  7. #7
    Registered User
    Join Date
    10-07-2015
    Location
    Belgium
    MS-Off Ver
    2010
    Posts
    5

    Re: Formatting literally text

    Thanks MrShorty.

    The thing you suggest in steps is actually something I'm avoiding to do

    That's why I'm looking for a way to i.e. write something like TEXT(A1, "0.00.000") and formatting to 1.02.034 the original value of 1.2.34. Perhaps this is not possible.

    Your initial suggestion of text to columns + CONCATENATE() and TEXT() combination works perfectly fine and solves my case. So thanks for this suggestion.

    Best regards,

    Meibrah

  8. #8
    Registered User
    Join Date
    10-07-2015
    Location
    Belgium
    MS-Off Ver
    2010
    Posts
    5

    Re: Formatting literally text

    Thanks MrShorty.

    The thing you suggest in steps is actually something I'm avoiding to do

    That's why I'm looking for a way to i.e. write something like TEXT(A1, "0.00.000") and formatting to 1.02.034 the original value of 1.2.34. Perhaps this is not possible.

    Your initial suggestion of text to columns + CONCATENATE() and TEXT() combination works perfectly fine and solves my case. So thanks for this suggestion.

    Best regards,

    Meibrah

  9. #9
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Formatting literally text

    The TEXT Function is for converting numeric values to text with formatting so it cannot be used directly on your text strings. You would need to convert them to numbers first as Mr Shorty proposed in post #4
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  10. #10
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Formatting literally text

    Might this be something that does what you want? It is on the edge of mega-formula.

    Row\Col
    A
    B
    C
    2
    1.09.13 1.09.013 In b2 =TEXT(LEFT(A2,1)/1440+(MID(A2,3,2)/86400)+RIGHT(SUBSTITUTE(A2,".",REPT(" ",20),2),10)/86400000,"m.ss.000")
    3
    4.2.1 4.02.001
    4
    4.3.448 4.03.448


    This manipulates the string and formats it as "time".

    Edit I probably ought to try and explain this one. It coerces the string into "pretending" to be a time value as MrShorty and ChemistB suggested above. If you are not aware of it time is a numeric value ..... a decimal fraction of a day. This formula parses each section. The first is coerced into minute fractions of a day ... hence the divide by 1440 (1440 minutes in a day). The next section is coerced into second fractions of a day or multiples of 1/86400 of a day. The next is multiples of one-thousandth of seconds. Summed up they equal the decimal fraction of a day which lends itself to TEXT with a time formatting (substituting conventional ":" separations with ".").

    It's an admittedly rather "cheesy" way to do it. It was the most compact single formula approach I could come up with, and it seems to do what you want.

    Another edit BTW if there are numbers larger than 60 in the middle section this isn't going to work.
    Last edited by FlameRetired; 10-07-2015 at 03:13 PM.
    Dave

+ 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: 1
    Last Post: 08-28-2013, 09:07 AM
  2. Replies: 15
    Last Post: 02-10-2009, 01:36 PM
  3. sum literally
    By rax in forum Excel General
    Replies: 10
    Last Post: 12-11-2008, 12:40 PM
  4. [SOLVED] Copying a formula "literally"
    By ArthurJ in forum Excel General
    Replies: 8
    Last Post: 02-07-2006, 04:40 PM
  5. Im literally a beginner, please help!
    By genuinegal via OfficeKB.com in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-10-2005, 08:05 AM
  6. EVERY Chord, Scale and Mode for GUITAR.. Literally!!
    By Open Minded215 in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 01-26-2005, 05:06 AM
  7. Replies: 3
    Last Post: 01-13-2005, 08: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