+ Reply to Thread
Results 1 to 8 of 8

Formatting a cell to display a space at mid point of value

  1. #1
    Registered User
    Join Date
    05-15-2012
    Location
    Australia
    MS-Off Ver
    Mac Office 365 (v16)
    Posts
    24

    Formatting a cell to display a space at mid point of value

    Hi All,

    The formula is OK - but I'm not sure if I can get it operate on the cell the data is entered in.

    C2 = 123456, I want it to display as 123 456.

    The data will be different lengths - but all lengths will be even numbers

    So formula is:

    =LEFT(C2,(LEN(C2)/2)) &" "& RIGHT(C2,(LEN(C2)/2))

    I wan the result displayed in the same cell the data is entered into - in this case C2.

    So - essentially - can conditional formatting do this - I've had a play and can't make it work.

    Thanks

    Mark

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,447

    Re: Formatting a cell to display a space at mid point of value

    As an example, use a Custom Format, "### ###", without quotes.

    Test the cell length to determine which format to use: "## ##", "### ###", "#### ####", etc


    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    05-15-2012
    Location
    Australia
    MS-Off Ver
    Mac Office 365 (v16)
    Posts
    24

    Re: Formatting a cell to display a space at mid point of value

    thx - sorry - might be dumb Q - but how do I test for length?

  4. #4
    Registered User
    Join Date
    05-15-2012
    Location
    Australia
    MS-Off Ver
    Mac Office 365 (v16)
    Posts
    24

    Re: Formatting a cell to display a space at mid point of value

    the other thing I wish to do is conditionally format decimal places

    eg

    if C1=miles

    then C4 formatted to 2 decimal places

    again - want this done in the data entry field

    thanks

  5. #5
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,447

    Re: Formatting a cell to display a space at mid point of value

    You test the length with LEN.

    =LEN(C4)

    You'd need various CF checks to test and format each length. And maybe a maximum value.

    Try: ### #"."## to take 6 digits, insert a space and a decimal point Note the quotation marks around the decimal point.


    Regards, TMS

  6. #6
    Registered User
    Join Date
    05-15-2012
    Location
    Australia
    MS-Off Ver
    Mac Office 365 (v16)
    Posts
    24

    Re: Formatting a cell to display a space at mid point of value

    thanks -

    I'm not sure what CF is and where to use the LEN function.

  7. #7
    Registered User
    Join Date
    06-01-2013
    Location
    Columbus, ms
    MS-Off Ver
    Excel 2013
    Posts
    68

    Re: Formatting a cell to display a space at mid point of value

    Quote Originally Posted by mbender View Post
    thanks -

    I'm not sure what CF is and where to use the LEN function.
    The problem I'm having in thinking through a solution is that you want the results to appear in the same sell you type into. Conditional formating works base on a true/false outcome. The formula you proposed does not produce a true/false result. If you try to manually type the number into the the cell and you have a formula there you obviously write over the formula. If you know how many possible lengths you might have you could come up with one conditional formatting for each size. so if the length= 4 apply this formatting, if the length=6 apply this formatting, etc.

    I wish I could help you a little more but but if you are hard set on the input cell being the same cell as the formatted cell your options are somewhat limited.

  8. #8
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,447

    Re: Formatting a cell to display a space at mid point of value

    I keep making suggestions based on very little data and you seem unable to adapt them to meet your needs.

    It might help us to help you if you post a sample workbook with all the examples of your data and how you want them to look.

    Warning: The formatting and/or conditional formatting don't change the underlying data, just the way it looks. So, inserting a decimal point using formatting doesn't change the value in the cell.

    Regards, TMS

+ 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