+ Reply to Thread
Results 1 to 5 of 5

Write a subroutine in a module to change case upon exit of a cell to upper case

  1. #1
    Registered User
    Join Date
    01-12-2013
    Location
    Kansas
    MS-Off Ver
    Excel 2010
    Posts
    6

    Write a subroutine in a module to change case upon exit of a cell to upper case

    Hi everyone. I'm stuck on how to get this to work. Column M in my worksheet is used for U.S. state codes. If someone entering data into a cell in column M in the worksheet enters ca for California, the text should be converted to uppercase as soon as the cell is exited (it should read CA upon exit).

    The code below does not work. I have it in a module. I have some code written in a worksheet_change event that does work, but I want to learn how to get it to work if I place it in a module. I'm trying to learn VBA and I just can't seem to grasp this concept.


    Please Login or Register  to view this content.

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Write a subroutine in a module to change case upon exit of a cell to upper case

    "Automatic" events must be called from a sheet module event macro, like Worksheet_Change. There can only be ONE of those, so you will have to teach it to do all the things you want.

    For this:
    Please Login or Register  to view this content.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Valued Forum Contributor xlbiznes's Avatar
    Join Date
    02-22-2013
    Location
    Bahrain
    MS-Off Ver
    Excel 2007
    Posts
    1,223

    Re: Write a subroutine in a module to change case upon exit of a cell to upper case

    Hi,

    when you put any code into a module, you need to invoke this by calling it.

    Here the trigger to fire your code is the change in the column "M" , hence you will fire any code only when this worksheet_change event occurs.
    Happy Computing ,

    Xlbiznes.

    To show your appreciation please click *

  4. #4
    Registered User
    Join Date
    01-12-2013
    Location
    Kansas
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Write a subroutine in a module to change case upon exit of a cell to upper case

    Is there a way to write code in a module where:
    1) Anytime sheet 2 is active
    2) And a cell in column "M" is changed to a state code that is not upper case, such as "ca"
    3) When that cell in column "M" is exited, the state code is should be changed to upper case and should read "CA"

    I don't want this to go in the Worksheet_Change event because I have other things in that event already.

  5. #5
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Write a subroutine in a module to change case upon exit of a cell to upper case

    You will add this to your Worksheet_Change macro that exists already.

+ 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. Replies: 3
    Last Post: 10-30-2009, 04:00 PM
  2. Replies: 8
    Last Post: 07-04-2006, 09:35 AM
  3. [SOLVED] How to change mixed case to upper case in Excel for all cells
    By WordAlone Network in forum Excel General
    Replies: 6
    Last Post: 02-14-2006, 08:10 PM
  4. Replies: 2
    Last Post: 12-09-2005, 05:15 AM
  5. How do I change a column in Excel from upper case to lower case?
    By Debbie Kennedy in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 05-02-2005, 02:06 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