+ Reply to Thread
Results 1 to 14 of 14

Sentence case

  1. #1
    Forum Contributor
    Join Date
    08-23-2011
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    404

    Sentence case

    Hi all,

    How do I enforce for ranges A1:A10 and C1:C10 that whatever is entered in these cells is changed to sentence case, i.e. "today it is Raining." will change to "Today it is raining.".

    I thought of having helper columns with the following formula that would then paste over the ranges on a Workbook.close event but it seems long-winded and not the right way of doing it.

    Formula for helper columns:

    Please Login or Register  to view this content.
    Any VBA ideas?

  2. #2
    Valued Forum Contributor abduljaleel.mca's Avatar
    Join Date
    02-13-2013
    Location
    Chennai, India
    MS-Off Ver
    MS 365 Business
    Posts
    326

    Re: Sentence case

    Use

    Please Login or Register  to view this content.

  3. #3
    Forum Expert MickG's Avatar
    Join Date
    11-23-2007
    Location
    Banbury,Oxfordshire
    Posts
    2,650

    Re: Sentence case

    Try this:-
    Please Login or Register  to view this content.
    Regards Mick
    Last edited by MickG; 04-16-2014 at 08:43 AM.

  4. #4
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,655

    Re: Sentence case

    Try this........
    Please Login or Register  to view this content.
    Hope this helps.
    Regards
    sktneer


    Treat people the way you want to be treated. Talk to people the way you want to be talked to.
    Respect is earned NOT given.

  5. #5
    Forum Contributor
    Join Date
    08-23-2011
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    404

    Re: Sentence case

    Hi Mick/Skt,

    I'm placing your respective codes in Sheet1 but nothing is occurring? Am I missing something. I added it to ThisWorkbook but the same thing.

  6. #6
    Forum Expert MickG's Avatar
    Join Date
    11-23-2007
    Location
    Banbury,Oxfordshire
    Posts
    2,650

    Re: Sentence case

    See attached file:-
    The code is set in the Sheet module for your Data.
    Attached Files Attached Files

  7. #7
    Forum Contributor
    Join Date
    08-23-2011
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    404

    Re: Sentence case

    Hi Mick,
    in
    This is quite odd. I have no doubt that it's working however when I type (without quotes) 'hello This is Here' in A6 it remains exactly the same?

  8. #8
    Forum Expert MickG's Avatar
    Join Date
    11-23-2007
    Location
    Banbury,Oxfordshire
    Posts
    2,650

    Re: Sentence case

    It may be I stepped through the code and did not get to the end to "Enable Events" if you copy that last line
    Please Login or Register  to view this content.
    and just run it in a button on the sheet. i think it will fix it.

  9. #9
    Forum Contributor
    Join Date
    08-23-2011
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    404

    Re: Sentence case

    Hi Mick,

    Yep - working! How is this so? I am using this instead of the button. Would you mind explaining?

    Please Login or Register  to view this content.

  10. #10
    Forum Expert MickG's Avatar
    Join Date
    11-23-2007
    Location
    Banbury,Oxfordshire
    Posts
    2,650

    Re: Sentence case

    That basically is the same as my first code , except you are calling a sub instead of directly running that bit of code.

    You could still get the same problem as before, if you where to step through only half the code, because by not completing the code and setting the "EnableEvents" to true, all subsequent Change events would not be able to run.

    The purpose of the "Application.EnableEvents" code is to stop the code from running an endless loop. When you alter the contents of the cell you change its value, this triggers the code to run again, this can then repeats itself endlessly.

    You really need to also change the similar line as below, because if you select a "Range" of cells you will get an error.
    Please Login or Register  to view this content.

  11. #11
    Forum Contributor
    Join Date
    08-23-2011
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    404

    Re: Sentence case

    Thank you. The only thing I don't understand is how someone (other users) could only step through half the code? They would just be entering/amending cell values so the macro would fire and that would be it?

    Would I change it to:

    Please Login or Register  to view this content.

  12. #12
    Forum Expert MickG's Avatar
    Join Date
    11-23-2007
    Location
    Banbury,Oxfordshire
    Posts
    2,650

    Re: Sentence case

    No, it only if the developer was playing with the code by stepping through it "F8" that he might leave the "EnableEvent" at False, other than that it would/should not happen.

    That line of code need to be "= 1" to stop the code if the Range (number) of cells Selected was greater than 1.

  13. #13
    Forum Contributor
    Join Date
    08-23-2011
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    404

    Re: Sentence case

    Thank you Mick and thank you for explaining it to me. Very kind.

  14. #14
    Forum Expert MickG's Avatar
    Join Date
    11-23-2007
    Location
    Banbury,Oxfordshire
    Posts
    2,650

    Re: Sentence case

    You're welcome
    Regrds Mick

+ 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. [SOLVED] Split Capital case and Sentence case from a cell
    By Latha Mani in forum Excel General
    Replies: 8
    Last Post: 03-26-2014, 03:29 AM
  2. [SOLVED] Change Capitals to Sentence Case
    By do in forum Excel General
    Replies: 5
    Last Post: 07-02-2010, 04:50 AM
  3. Sentence case FORMULA??
    By simjambra in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 03-12-2009, 08:30 AM
  4. Change code HELP. Sentence Case
    By Corey in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-12-2006, 10:10 PM
  5. Replies: 2
    Last Post: 05-16-2006, 12:10 PM

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