+ Reply to Thread
Results 1 to 4 of 4

custom formating

  1. #1
    Registered User
    Join Date
    01-26-2007
    Posts
    2

    custom formating

    Hi all,

    In a spreadsheet i'm working on, negative numbers are formatted with parentheses.

    In one cell, I have a formula like this :

    =A1&"/"&B1

    That works great for positive numbers, but for negative numbers, i "lose" the parentheses format.

    Is there a way to tweak custom formats to display something like : (2)/(3) with negative numbers instead of the -2/-3 that I'm getting now ?

    Cheers

  2. #2
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Hi,

    This would work if both formula's are negative

    =IF(AND(SIGN(A1)=-1,SIGN(B1)=-1),SUBSTITUTE("("&A1&")/("&B1&")","-",""),A1&"/"&B1)

    VBA Noob
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

  3. #3
    Registered User
    Join Date
    01-26-2007
    Posts
    2
    Thanks VBA Noob,

    I use : ="("&-A1&")/("&-B1&")"

    This works because as you said, I know for sure that both numbers are negative.

    I only wish there was a way to create a custom format to automate that.

    Thanks though.

  4. #4
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675
    Use the TEXT function, something like

    =TEXT(A1,"0;(0);0")&"/"&TEXT(B1,"0;(0);0")

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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