+ Reply to Thread
Results 1 to 5 of 5

Change alignment based on if cell is text or number.

  1. #1
    Registered User
    Join Date
    05-26-2011
    Location
    New Jersey
    MS-Off Ver
    Excel 2007
    Posts
    11

    Change alignment based on if cell is text or number.

    This website has been incredibly helpful with teaching me a lot about the power of excel, so thank you.

    I have a fairly simple question that I have not been able to find an answer to online.

    What I want to do is use either a conditional formatting or custom formatting to change the alignment of my cells. If a cell contains text I want the cell to be center aligned, but right aligned if it contains numbers. My initial thought is to use indents, but my column widths are all going to be diferent, so that may not be appropriate. It seems like custom formatting might hold a solution, but I don't understand that enough.

    Attached is a very simple example of what I want. Thanks for the help in advance.

    Also, I cannot use macros at all in my spreadsheet so any solution cannot contain them.
    Attached Files Attached Files

  2. #2
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,983

    Re: Change alignment based on if cell is text or number.

    Set the cell alignment to centre align, then use:
    * General
    as a custom number format
    Everyone who confuses correlation and causation ends up dead.

  3. #3
    Registered User
    Join Date
    05-26-2011
    Location
    New Jersey
    MS-Off Ver
    Excel 2007
    Posts
    11

    Re: Change alignment based on if cell is text or number.

    Wow thanks for the lightning fast response.

    That works,but I have one follow up question, I want to retain the number formatting where negative numbres are in "()". When I use "* general" the "-" is left alligned and the number is right aligned. Looks super goofy. Any additional insight would be great.

  4. #4
    Registered User
    Join Date
    05-26-2011
    Location
    New Jersey
    MS-Off Ver
    Excel 2007
    Posts
    11

    Re: Change alignment based on if cell is text or number.

    Nevermind I figured out how. Just center aligned the text and then used the "," format for numbers. I can't believe the solution was that easy. Thanks for the help.

  5. #5
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,983

    Re: Change alignment based on if cell is text or number.

    Glad to help.

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save

+ 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