+ Reply to Thread
Results 1 to 8 of 8

Trimming Spaces before and after

  1. #1
    Registered User
    Join Date
    01-21-2004
    Location
    Alabama
    Posts
    35

    Trimming Spaces before and after

    I have a column of cells where users put in "Y" for yes and "N" for no. However, when i count the Y's and N's, if there is a space after the letter, it will not count the character. I can't depend on users to remove the spaces,they are not that computer literate. Besides spaces are hard to see.

    I'm actually using the sumproduct function instead of count but i figured the method would be similar but just in case, i thought i would make sure.

    How can i trim the spaces? So that "Y" will be treated the same as " Y "?

    Thanks!

  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
    Take a look at Trim under excel help

    You may also want to consider setting up a dropdown list

    http://www.contextures.com/xlDataVal01.html

    VBA Noob
    Last edited by VBA Noob; 01-09-2008 at 03:42 PM.
    _________________________________________


    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-21-2004
    Location
    Alabama
    Posts
    35
    Thanks for the fast reponse. Instead of a drop down list. I think a check box might be better.

    Does this require programming to retrieve the value with the sumproduct function?

    Thanks!

  4. #4
    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
    Does this require programming to retrieve the value with the sumproduct function?
    You could link it to a cell to return true or false

    http://www.bettersolutions.com/excel...T423111411.htm

    or you could use a tick mark

    http://www.excelforum.com/showthread...highlight=tick

    VBA Noob

  5. #5
    Registered User
    Join Date
    01-21-2004
    Location
    Alabama
    Posts
    35
    I found this function called trim() but it will not allow me to do
    =COUNTIF(trim(A2:A5),"y") and i can't format the cell to trim automatically that i know of.

  6. #6
    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
    Try

    =SUMPRODUCT(--(TRIM(A2:A5)="y"))
    VBA Noob

  7. #7
    Registered User
    Join Date
    01-21-2004
    Location
    Alabama
    Posts
    35
    Wow! That will work!
    Thanks
    Last edited by VBA Noob; 01-09-2008 at 04:47 PM.

  8. #8
    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
    Your welcome

    VBA Noob

+ 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