+ Reply to Thread
Results 1 to 16 of 16

Proper application not handling apostrophes

  1. #1
    Valued Forum Contributor
    Join Date
    08-10-2012
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    721

    Proper application not handling apostrophes

    I have a macro that changes my text to Proper but it cant handles apostrophes, so for example

    PETER'S HOUSE

    Shoule become Peter's House, but instead the macro changes it to Peter'S House

    How can i amend this?

    Please Login or Register  to view this content.

    For your info the full macro is below

    Please Login or Register  to view this content.

  2. #2
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,788

    Re: Proper application not handling apostrophes

    Please Login or Register  to view this content.


    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
    Mark your thread as Solved


    If the suggestion helps you, then Click *below to Add Reputation

  3. #3
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,645

    Re: Proper application not handling apostrophes

    Try VBA's StrConv function.
    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

  4. #4
    Valued Forum Contributor
    Join Date
    08-10-2012
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    721

    Re: Proper application not handling apostrophes

    Sixsense, I get a run time error 13, type mismatch on your code
    thuis line is highlighted
    Please Login or Register  to view this content.
    Norie your code delivers the same error on this line
    Please Login or Register  to view this content.

  5. #5
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,645

    Re: Proper application not handling apostrophes

    That probably means the area the loop is currently on consists of more than one cell, though you would also get the error if you had a cell with an error value.

    If it's the former try this.
    Please Login or Register  to view this content.

  6. #6
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,788

    Re: Proper application not handling apostrophes

    Quote Originally Posted by nickmax1 View Post
    Sixsense, I get a run time error 13, type mismatch on your code
    You may be missing the With application and end with which is mentioned in my code

  7. #7
    Valued Forum Contributor
    Join Date
    08-10-2012
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    721

    Re: Proper application not handling apostrophes

    Sixthsense,
    no i copied and pasted your code in its entirety and still i get that error.

    Norie, your code runs no problem but does not solve the apostrophe issue!!

  8. #8
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,788

    Re: Proper application not handling apostrophes

    Both the methods works fine at my end.

    Norie's StrConv() vba function suggestion is the right method for your case

  9. #9
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,645

    Re: Proper application not handling apostrophes

    Are you sure?

    It worked with your example and some others I tried?

    Can you attach a sample workbook with dummy data?
    Last edited by Norie; 05-26-2015 at 07:39 AM.

  10. #10
    Valued Forum Contributor
    Join Date
    08-10-2012
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    721

    Re: Proper application not handling apostrophes

    try this one
    Attached Files Attached Files

  11. #11
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,645

    Re: Proper application not handling apostrophes

    The only apostrophes I can find in the workbook are in formulas.

    I definitely don't see any in $C$17:$C$190 or $C$193:$C$275, which are the 2 areas the code you posted is looping, those ranges only appear to have numbers.

    Mind you if there are apostrophes in the real data it might help if I post the right code.
    Please Login or Register  to view this content.

  12. #12
    Valued Forum Contributor
    Join Date
    08-10-2012
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    721

    Re: Proper application not handling apostrophes

    aha the "right" code did the trick!

    sorry for the test spreadsheet that was an old one I needed to amend the numbers for text. but no matter the code works thanks so much!

  13. #13
    Valued Forum Contributor
    Join Date
    08-10-2012
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    721

    Re: Proper application not handling apostrophes

    Norie/Sixthsense

    I noticed after several days that the code doesnt quite work as expected. For the most part its perfect but in instances like the following:

    John/PETER - I expect the code to rewrite this as John/Peter but instead i get John/peter

    O'malleys - I expect this to be O'Malleys. Instead I get O'malleys

    Finally,
    s.a.b. Miller I would expect to see S.A.B. Miller but i get S.a.b. Miller

  14. #14
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,645

    Re: Proper application not handling apostrophes

    StrConv and Proper aren't 'intelligent' enough to handle cases like that I'm afraid.

  15. #15
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,788

    Re: Proper application not handling apostrophes

    May be try using split() to split each words on that cell with space as the delimiter and apply the case sensitivity based on the placement of single quote

  16. #16
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,645

    Re: Proper application not handling apostrophes

    nickmax1

    If you want to deal with the type of examples you posted you would need to write your own code.

    I've had to do that in the past, especially when handling names with apostrophes, eg O'NEILL and Mc/Mac names.

+ 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. Proper usage of Application.ScreenUpdating
    By mreFF in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 07-14-2014, 03:39 PM
  2. [SOLVED] Dealing with Application Messages when running VBA - Error Handling
    By JungleJme in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 09-21-2012, 10:21 AM
  3. Proper handling of "cancel" for range-type input box response (type 8)
    By MCCCLXXXV in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 10-28-2011, 11:19 AM
  4. Error handling with a handling routine
    By ben in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-15-2005, 11:06 AM
  5. [SOLVED] Problem using 'PROPER' with apostrophes
    By borobutch in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-16-2005, 10:06 AM

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