+ Reply to Thread
Results 1 to 4 of 4

Custom format considering a dash between two numbers

  1. #1
    Registered User
    Join Date
    03-25-2004
    Posts
    54

    Custom format considering a dash between two numbers

    Hey, guys.

    Please, is it possible to do something like this?

    I have a product code composed by two numbers separated by a dash in a cell (say A1). Example: 34-9.

    I want to format that cell in a way it will show this: C0034-E0009.

    I've already tried custom format like this "C0000-E0000", but of course it didn't work out.

    I know how to do it with formulas and functions, if I separate that number into two cells -- for example: TEXT(A1,"C0000")&"-"&TEXT(B1,"E0000") --, but that's not what I actually need. If I do so, the product code will get changed from 34-9 to C0034-E0009 and this will be a real pain. I don't want to change the code, I just want it to be shown differently. In other words, I will still type 34-9, but it will show C0034-E0009 in the same cell. It's just like dates, I mean, we always type them the right way, but we format the cell so it shows the dates in different ways.

    Well, that's it. Is it possible? If I have to use a custom VBA function, created specifically for this purpose, no problem.

    Thanks for your attention.

    brunces

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

    Re: Custom format considering a dash between two numbers

    The value 34-9 is a text string, and Excel has very limited options for formatting text strings. (See the paragraph "Include a section for text entry" here https://support.office.com/en-us/art...2-09fab54be7f4 ).

    I don't see any way (VBA or otherwise) to have a cell's value contain the text string "34-9" and have the cell display the text string "C0034-E0009" (though I will be happy to be proven wrong). Every solution I can readily see would completely replace the "34-9" text string with the "C0034-E0009" text string, which does not sound like what you want. Or I can see solutions similar to your "concatenate several smaller text strings into the final text string", but, again, those do completely change the text from one string to the other.

    I would suggest that you rethink this approach to the problem you have. What exactly is going on in this spreadsheet that you want a cell to contain the value/text string "34-9" but display the text string "C0034-E0009"?
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  3. #3
    Registered User
    Join Date
    03-25-2004
    Posts
    54

    Re: Custom format considering a dash between two numbers

    MrShorty, thanks for your reply.

    Well, the point here is this... I have a so called Product code composed by the Client and the Equipment codes, separated by a dash. That's the reason for the C and E (C9999-E9999). This product code was created to make sure the code is unique and that it will never be duplicated. It's been working perfectly well since the beginning. However, we've always tried to follow and use some kind of data standardization/pattern, specially for "good looking purposes". Codes without a pattern make reports very ugly in most of cases.

    So, for the time being, our Product code is "ugly" like that, I mean, two distinct numbers separated by a dash, without any pattern or mask. Now, we're trying to change that, however we already have a -- not huge, but very -- big data base with those numbers, and lots of formulas that link them in different spreadsheets. That's why, at first, we want to try to just format what we already have, like a mask, because if we change the code itself, we will have some little problems. For example, the file will definitely get bigger because, imagine, today we store "34-9", I mean, a code with 4 characters; and if we change it, it'll be "C0034-E0009", an 11 characters code for all the records. Big difference. Another thing... Today, when we want to search for a product, we just type "34-9", simple like that. And if we change the code, we will have to type all the 11 characters just to find a record. That will be a real pain.

    But... just like you said, it seems there's nothing that can be done regarding text formatting, so we will have to figure out what to do. Maybe we spit the number into two columns and format them separately for searching and reports matters. I don't know. Time for brainstorming now.

    Anyway, thank you very much for your attention, MrShorty. I appreciate it.

    brunces

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

    Re: Custom format considering a dash between two numbers

    I have little to no experience with these kind of database issues, so there could be some value in consulting someone who is better at designing and working with databases.
    Maybe we spit the number into two columns and format them separately for searching and reports matters. I don't know. Time for brainstorming now.
    This makes a lot of sense to me. Have a few different columns/fields -- a "short code" field and a "long code" field, maybe. or "old code" field and "new code" field. As you can see from your concatenation formula, it should be readily possible to designate one of those fields as the data entry field and make the other field(s) a function of the main entry field.

+ 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. How do a format numbers in a custom way?
    By christinaAnnmerkle in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 03-29-2016, 10:51 AM
  2. custom format for numbers
    By elmasguapo in forum Excel General
    Replies: 3
    Last Post: 11-10-2015, 08:17 PM
  3. Format Phone Numbers With A Period Instead Of A Dash?
    By karmadog62 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-03-2014, 04:59 PM
  4. Custom Format Issue with Numbers
    By pdias2 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 08-20-2014, 01:57 PM
  5. Replies: 1
    Last Post: 10-17-2012, 09:18 AM
  6. [SOLVED] Merging Numbers with custom format - how to keep format
    By oddcarout in forum Excel General
    Replies: 3
    Last Post: 08-15-2012, 07:54 PM
  7. [SOLVED] Custom Format for Numbers
    By Dr. Sachin Wagh in forum Excel General
    Replies: 4
    Last Post: 01-14-2006, 01:50 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