+ Reply to Thread
Results 1 to 14 of 14

Custom Number Format Formula

  1. #1
    Registered User
    Join Date
    08-03-2015
    Location
    United States
    MS-Off Ver
    Excel 2013
    Posts
    38

    Exclamation Custom Number Format Formula

    Hello,

    I am working on an excel spreadsheet for work and I need help creating a custom formula. At work we use cost codes in order to hide our cost from the customers. It would be very helpful to be able to enter our cost in standard currency format (i.e., 195; 11; 12.99; 0.75), and have it automatically convert to our cost code format (i.e., 195; 11; 1299; 0075). Can someone please help me find the appropriate Public Function that I need in order to create my custom formula, as well as help me with how to write the custom formula??

    I need there to be zeros where there is a tens place if it is a single digit number, and I need two zeros for the tens and ones place if it is cents only. If it is a whole, two-digit or three-digit number then it can stay as is. If there is a decimal place, then I need the decimal removed. Below are examples of how I would need the codes to be formatted:

    .45 = 0045
    .50 = 0050
    5 = 05
    4.95 = 0495
    11 = 11
    11.50 = 1150
    250 = 250
    199.95 = 19995
    1000 = 1000
    1000.05 = 100005

    Is there a way to create a formula to satisfy these conditions?? I would really appreciate it!

    Thank you!!
    Last edited by rosethorn5; 08-03-2015 at 03:51 AM.

  2. #2
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,196

    Re: Custom Number Format Formula

    Try ...

    Data in A1

    =IF(MOD(A1,1)=0,TEXT(A1,"0"),TEXT(A1*100,"0000"))

  3. #3
    Registered User
    Join Date
    08-03-2015
    Location
    United States
    MS-Off Ver
    Excel 2013
    Posts
    38

    Re: Custom Number Format Formula

    Thank you. I tried it, but when I entered it exactly, it showed up in the cell as the formula, not as a numberical value. :-/

  4. #4
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,196

    Re: Custom Number Format Formula

    The cell you entered the formula in was formatted as text: format as general.

  5. #5
    Registered User
    Join Date
    08-03-2015
    Location
    United States
    MS-Off Ver
    Excel 2013
    Posts
    38

    Re: Custom Number Format Formula

    You're totally right! The formula worked perfectly as I need it to, thank you SO MUCH!!

  6. #6
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,196

    Re: Custom Number Format Formula

    Glad it's sorted. Can you mark this as SOLVED.

  7. #7
    Registered User
    Join Date
    08-03-2015
    Location
    United States
    MS-Off Ver
    Excel 2013
    Posts
    38

    Re: Custom Number Format Formula

    I sure can. This is my first time on this. Will you tell me where I can mark it as solved?

  8. #8
    Forum Expert Sam Capricci's Avatar
    Join Date
    06-14-2012
    Location
    Palm Harbor, Florida
    MS-Off Ver
    16.84 for Mac MS 365
    Posts
    8,499

    Re: Custom Number Format Formula

    at the top of the post is a dropdown section titled thread tools, use the dropdown and select solved there. And don't forget to give John a bump to his reputation for helping you. He'll appreciate it.
    Make contributors happy, click on the "* Add Reputation" as a way to say thank you.
    Sam Capricci

  9. #9
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,196

    Re: Custom Number Format Formula

    @Sambo Kid: thank you. Not too bothered about the "reputation" - for me a simple thank you (if offered) is fine!

  10. #10
    Registered User
    Join Date
    08-03-2015
    Location
    United States
    MS-Off Ver
    Excel 2013
    Posts
    38

    Re: Custom Number Format Formula

    Quote Originally Posted by JohnTopley View Post
    Try ...

    Data in A1

    =IF(MOD(A1,1)=0,TEXT(A1,"0"),TEXT(A1*100,"0000"))
    Hello, this formula works perfectly, with the exception of when using single digit whole numbers. Otherwise, every other type of number is exactly how I need it to be. Below are examples of how I need each type of number to be formatted into. In parenthesis I've notated which one is not being formatted the way I need it to be:

    .45 = 0045
    .50 = 0050
    5 = 05 (shows up as 5 instead of 05)
    4.95 = 0495
    11 = 11
    11.50 = 1150
    250 = 250
    199.95 = 19995
    1000 = 1000
    1000.05 = 100005

  11. #11
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,196

    Re: Custom Number Format Formula

    See next response.
    Attached Files Attached Files
    Last edited by JohnTopley; 08-04-2015 at 09:23 AM. Reason: Wrog resonse

  12. #12
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,196

    Re: Custom Number Format Formula

    Sorry .. Ignore my last post ! my mistake ... change to

    =IF(MOD(A1,1)=0,TEXT(A1,"00"),TEXT(A1*100,"0000"))


    0.45 0045
    0.5 0050
    5 05
    4.95 0495
    11 11
    11.5 1150
    250 250
    199.95 19995
    1000 1000
    1000.05 100005

  13. #13
    Registered User
    Join Date
    08-03-2015
    Location
    United States
    MS-Off Ver
    Excel 2013
    Posts
    38

    Re: Custom Number Format Formula

    YES PERFECT!!! Thank you soooo much!!

  14. #14
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,196

    Re: Custom Number Format Formula

    Apologies for the error: I should engage brain before responding!

+ 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. Need formula or code to convert number(s) from custom format to number format
    By tuongtu3 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-12-2015, 07:44 PM
  2. Custom Number Format
    By Frank Curry in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 02-24-2013, 05:06 AM
  3. Conveying custom number format to new cell via formula
    By delirium in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 04-03-2009, 12:36 PM
  4. custom number format in formula
    By pbruce61 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 12-20-2007, 10:19 AM
  5. how do I add phone number format as a permanent custom format?
    By frustratedagain in forum Excel General
    Replies: 3
    Last Post: 02-03-2006, 11:52 PM
  6. Format a cell with a custom number format
    By Armor in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 01-29-2006, 07:30 PM
  7. Custom number format always defaults last number to 0.
    By scubadave in forum Excel General
    Replies: 2
    Last Post: 06-15-2005, 06:05 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