+ Reply to Thread
Results 1 to 12 of 12

Mixed case requirements in same cell!

  1. #1
    Forum Contributor
    Join Date
    03-22-2006
    Location
    UK
    MS-Off Ver
    Office 2013
    Posts
    275

    Mixed case requirements in same cell!

    Hi all

    I have this code which is working fine but needs adjusting to take into account recent changes.

    Please Login or Register  to view this content.
    The change only affects "Sheet4 - Column 4" at the moment.

    I need the case change to handle the following so that:

    Smith (fs) appears as Smith (FS) not as Smith (fs)
    which is how the code currently handles the last 4 characters i.e. (fs).

    TIA ...spellbound

  2. #2
    Forum Expert
    Join Date
    03-23-2004
    Location
    London, England
    MS-Off Ver
    Excel 2019
    Posts
    7,079

    Re: Mixed case requirements in same cell!

    Why not do aText to Columns so the code does its job correctly on the surnames. As initials are isolated use a function to convert them to uppercase. Then concatenate the results.
    Regards
    Special-K

    Ensure you describe your problem clearly, I have little time available to solve these problems and do not appreciate numerous changes to them.

  3. #3
    Forum Contributor
    Join Date
    03-22-2006
    Location
    UK
    MS-Off Ver
    Office 2013
    Posts
    275

    Re: Mixed case requirements in same cell!

    Had already thought of that but would prefer a VBA solution if at all possible.

    These are not initials but a suffix added to some of the surname denoting a secondary account.

    Any takers on the VBA solution?

    spellbound

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Mixed case requirements in same cell!

    Hello Spellbound,

    I am not sure if I have placed the call to the macro in the correct place in your macro. It is in blue to make it easy see and change it if you need to.

    Macro to convert characters in parentheses to upper case
    Copy this code into a Standard VBA module.
    Please Login or Register  to view this content.
    Your Macro with the change
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  5. #5
    Forum Contributor
    Join Date
    03-22-2006
    Location
    UK
    MS-Off Ver
    Office 2013
    Posts
    275

    Re: Mixed case requirements in same cell!

    Hi Leith

    Thanks for the Macro and code.

    I pasted the Macro into a standard module and added the line of code to the original macro which is in 'This Workbook'.

    However, when I try to run the code, the line is in red and I get the following error message against the new line of code:

    Compile Error - Syntax Error
    Your new line of code appears to be in the right place, in that it relates to Column D of Sheet4.

    Any ideas ...spellbound

  6. #6
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Mixed case requirements in same cell!

    Hello Spellbound,

    The Target is passed into the Workbook_SheetChange event ByVal. The new macro takes the Range ByRef. Change the offending line of code to this...
    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    03-22-2006
    Location
    UK
    MS-Off Ver
    Office 2013
    Posts
    275

    Re: Mixed case requirements in same cell!

    Hi Leith

    Still having problems.

    As soon as I paste in the new line of code, I get the following error message:

    Compile Error - Expected Expression
    Very puzzling but beyond me ...spellbound

  8. #8
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Mixed case requirements in same cell!

    Hello Spellbound,

    Can you post the workbook for review?

  9. #9
    Forum Contributor
    Join Date
    03-22-2006
    Location
    UK
    MS-Off Ver
    Office 2013
    Posts
    275

    Re: Mixed case requirements in same cell!

    Hi Leith

    I have created a test workbook which includes the relevent sheet and code.

    Hope this helps ...spellbound
    Attached Files Attached Files

  10. #10
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Mixed case requirements in same cell!

    Hello Spellbound,

    I got it straightened out. Now if you include a characters in parentheses, they will be capitalized. I made a few typos in the code. Here is the corrected code which has already been added to the attached workbook. The corrections are in blue.

    Workbook Worksheet Change Event Code
    Please Login or Register  to view this content.
    Macro to Add Parentheses
    Please Login or Register  to view this content.
    Attached Files Attached Files

  11. #11
    Forum Contributor
    Join Date
    03-22-2006
    Location
    UK
    MS-Off Ver
    Office 2013
    Posts
    275

    Re: Mixed case requirements in same cell!

    Hi Leith

    Thanks for your continued efforts.

    Had a quick play and all seems well.

    Not around for a couple of days as I have to go for a knee operation today, so will fully implement it when I get back.

    Incidentally, you included another macro in the module of the attachment:

    Please Login or Register  to view this content.
    however I could'nt see where this is used.

    Thanks again ...spellbound

  12. #12
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Mixed case requirements in same cell!

    Hello Spellbound,

    Sorry to hear about the knee surgery. Hope all goes well and you recover fully.

    The macro was for troubleshooting. "Application.EnableEvents" is turned off at the beginning of the Worksheet_Change event in the "ThisWorkbook" module. If an error occurs while stepping through the code, the events will not be re-enabled unless the statement "Application.EnableEvents = True" is executed.

+ 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