+ Reply to Thread
Results 1 to 22 of 22

VBA macro UPPER auto case

  1. #1
    Forum Contributor
    Join Date
    10-22-2014
    Location
    Ontario
    MS-Off Ver
    365
    Posts
    222

    VBA macro UPPER auto case

    I am new to VBA macros and the one I made is not working.

    Found this with Google.

    Please Login or Register  to view this content.
    I created the macro and saved as Macro Enabled Workbook. I want certain cells to auto capitalize when I enter the data.

    This is how I would like it done:
    -B3 Capitalizes first letter of first and last name if possible. If not then all caps.
    -B5 All caps
    -B7, 8, 9 all caps
    -B12, 13 all caps

    Could use help on this.

    Thank you.Stock orderTemplate2.xlsm
    Last edited by JBeaucaire; 11-11-2014 at 06:16 PM. Reason: Added missing CODE tags. Please read and follow the Forum Rules, link above in the menu bar. Thanks.

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,464

    Re: VBA macro UPPER auto case

    Please Login or Register  to view this content.

    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


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

    Re: VBA macro UPPER auto case

    1) Right click on the Sheet1 tab and select View Code
    2) Paste this self-triggering event into the sheet module that appears:
    Please Login or Register  to view this content.
    3) Close the VBEditor and save your workbook

    Review the macro til it's clear what is happening at each step. Then try putting some values in your sheet1.
    Last edited by JBeaucaire; 11-11-2014 at 06:46 PM. Reason: Corrected CASE code. Thanks TMS
    _________________
    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!)

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,464

    Re: VBA macro UPPER auto case

    I guess this:

    Please Login or Register  to view this content.

    should be this:

    Please Login or Register  to view this content.

  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: VBA macro UPPER auto case

    Yes, yes! Thanks, corrected above. (hat-tip)

  6. #6
    Forum Contributor
    Join Date
    10-22-2014
    Location
    Ontario
    MS-Off Ver
    365
    Posts
    222

    Re: VBA macro UPPER auto case

    It's me who should be doing the hat-tipping to you both.

    So then...is it possible to copy all of this to the other units on the sheet? IOW A and B 3-15 to copy over to D and E 3-15 and so on. I suppose I can't just copy and paste right?

  7. #7
    Forum Contributor
    Join Date
    10-22-2014
    Location
    Ontario
    MS-Off Ver
    365
    Posts
    222

    Re: VBA macro UPPER auto case

    P.S. Since there are two macros now how does this work? Do I need to cancel one?

  8. #8
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,464

    Re: VBA macro UPPER auto case

    Extend the case lists to include the other ranges.

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

    Re: VBA macro UPPER auto case

    Let's do it this way, assuming you're going to copy the EXACT same codes from column A to all the other sections, we can make it dynamic, in this way it will look to the left of the cells you change to see what the text is. If the text is "Client" it will make your entry ProperCase. If it's "Account Type" or "Buy/Sell" etc... it will make your entry UPPERCASE.

    Another benefit is this means you can rearrange the order of the rows and it will still work!

    Please Login or Register  to view this content.

  10. #10
    Forum Contributor
    Join Date
    10-22-2014
    Location
    Ontario
    MS-Off Ver
    365
    Posts
    222

    Re: VBA macro UPPER auto case

    Umm... Do I do this on TMS or JBeaucaire macro. Can you tell I don't know what I am doing?

  11. #11
    Forum Contributor
    Join Date
    10-22-2014
    Location
    Ontario
    MS-Off Ver
    365
    Posts
    222

    Re: VBA macro UPPER auto case

    Sorry JBeaucaire I hadn't seen your reply #9. I will read it now.

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

    Re: VBA macro UPPER auto case

    Yes, remove your old macro completely, put this new one into the Sheet1 code module so it will activate itself as you type.

  13. #13
    Forum Contributor
    Join Date
    10-22-2014
    Location
    Ontario
    MS-Off Ver
    365
    Posts
    222

    Re: VBA macro UPPER auto case

    Ok. I am stuck.
    First do I leave both macros?
    Second it seems to copy over to other columns but when I tried to copy to A and B 17-29 a little window pops up MS Visual Basic - Run Time error '1004': Application-defined or object-defined error I can click End or Debug.

  14. #14
    Forum Contributor
    Join Date
    10-22-2014
    Location
    Ontario
    MS-Off Ver
    365
    Posts
    222

    Re: VBA macro UPPER auto case

    Once again I hadn't seen your post # 12. Ugh!

  15. #15
    Forum Contributor
    Join Date
    10-22-2014
    Location
    Ontario
    MS-Off Ver
    365
    Posts
    222

    Re: VBA macro UPPER auto case

    macro.jpgmacro.jpg

    Not sure if this attachment is view able. I really feel like I am taking a lot of your time now.

    I am still getting a End of Debug error when i try to copy into 17-29

    Stock orderTemplate2.xlsm

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

    Re: VBA macro UPPER auto case

    You need to remove the macro completely temporarily while you finish setting up your sheet. Once you have all the sections setup and ready to use, put the macro from post #9 back into that sheet module and give it a spin.

  17. #17
    Forum Contributor
    Join Date
    10-22-2014
    Location
    Ontario
    MS-Off Ver
    365
    Posts
    222

    Re: VBA macro UPPER auto case

    That got it. Extra work for you but good experience for me.

    Thanks a lot.

    Peter

  18. #18
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,464

    Re: VBA macro UPPER auto case

    Thanks for the rep.

  19. #19
    Forum Contributor
    Join Date
    10-22-2014
    Location
    Ontario
    MS-Off Ver
    365
    Posts
    222

    Re: VBA macro UPPER auto case

    Hi

    I have need of some further adjustments on my sheet. Should I just start over with a new post and hope the next person is able to continue where you left off? Alternatively are you also on the Commercial side?

    Thanks.

    Peter

  20. #20
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,464

    Re: VBA macro UPPER auto case

    Well, this question was answered and the thread marked solved. So, following up with a new question is not such a good idea. If you start a new thread, it will have a zero reply count and more people will take an interest. You can provide a link back to this thread:

    http://www.excelforum.com/excel-programming-vba-macros/1049142-vba-macro-upper-auto-case.html

    So, more interest and maintain the history.

    I don't answer questions in the Commercial Services sub-forum. JB does.


    Regards, TMS

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

    Re: VBA macro UPPER auto case

    I agree with TMS in regards to new threads garnering new eyes and possibly faster response as such. However if your followup question is really about this exact same topic, then continuing here would be fine and perhaps prudent.

    But resist the idea that any question regarding your workbook/project are all the same topic, they're not, and may truly belong in new threads, either in the free or CS forums. You could be pursuing several different discussions in several threads on issues that relate to the same workbook, but are not the same issue.



    Usually marking a thread SOLVED indicates your original topic was truly resolved, and most likely your new issues or need is because of something that is actually new, this a new thread is almost always the way to go in that regard.

  22. #22
    Forum Contributor
    Join Date
    10-22-2014
    Location
    Ontario
    MS-Off Ver
    365
    Posts
    222

    Re: VBA macro UPPER auto case

    Ok, thanks. Still new.

    Peter

+ 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. Auto convert lower case to Upper in same cell
    By russkris in forum Excel General
    Replies: 9
    Last Post: 08-08-2014, 06:49 AM
  2. [SOLVED] Lower Case to Upper Case but No Auto Correction : Solved by Mod (6StringJazzer)
    By HaroonSid in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 03-27-2014, 10:44 AM
  3. Auto display range as upper case
    By BigD1969 in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 09-15-2008, 07:43 PM
  4. Auto Upper Case
    By jamphan in forum Excel General
    Replies: 1
    Last Post: 01-05-2006, 05:50 PM
  5. Replies: 14
    Last Post: 08-25-2005, 10:05 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