+ Reply to Thread
Results 1 to 9 of 9

Set *everything* on userform to force caps?

  1. #1
    Registered User
    Join Date
    02-16-2018
    Location
    WI
    MS-Off Ver
    2016
    Posts
    56

    Set *everything* on userform to force caps?

    I am aware of how to manually set an individual text or listbox to force caps, however I was wondering if there is a way to force the entire userform to do so?

    I have several hundred objects here and I figured I would ask before going to town copy/pasting for an hour.

  2. #2
    Valued Forum Contributor ranman256's Avatar
    Join Date
    07-29-2012
    Location
    Kentucky
    MS-Off Ver
    Excel 2003
    Posts
    1,176

    Re: Set *everything* on userform to force caps?

    either in the CHANGE event
    txtbox = ucase(txtbox)

    or
    rather than program all of the controls, Ucase them all when user clicks SAVE button
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    02-16-2018
    Location
    WI
    MS-Off Ver
    2016
    Posts
    56

    Re: Set *everything* on userform to force caps?

    Even with that method I still need a line for every control sadly. I guess I should have clarified that better, when I said manually I guess I meant "individually with VBA".

    I was thinking about setting them all on the "save" event as you suggested, but again that's a loooot of copy and pasting so I was hoping for something that could just set everything on the entire userform at once, even if that includes labels.

  4. #4
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Re: Set *everything* on userform to force caps?

    Good evening IMMTech

    Loop through the objects - the code below will go through the textboxes. The example assumes there are only 3.
    Please Login or Register  to view this content.
    HTH

    DominicB

  5. #5
    Registered User
    Join Date
    02-16-2018
    Location
    WI
    MS-Off Ver
    2016
    Posts
    56

    Re: Set *everything* on userform to force caps?

    So, if I am looking at that correctly, the textboxes need to be named Textbox1, Textbox2, Textbox3, etc.

    Unfortunately I have named them all relative to what information they contain for ease of keeping up with my code and fixing problems that may occur.

    That would certainly do it otherwise.

    Perhaps in the future I will simply stick to the default textbox numbering and try to keep track of it solely with notes instead.

  6. #6
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Re: Set *everything* on userform to force caps?

    Hi IMM Tech

    You don't have to do it this way - I was just being lazy, and you didn't specify otherwise ...

    Use this code to run through all textboxes in Userform1, irrespective of how they are named.

    Please Login or Register  to view this content.
    HTH

    DominicB

  7. #7
    Registered User
    Join Date
    02-16-2018
    Location
    WI
    MS-Off Ver
    2016
    Posts
    56

    Re: Set *everything* on userform to force caps?

    So, thanks for the replies thus far, however to me this is remarkably vague and assumes I understand the context of each of those components and variables, which I do not.

    I'm gonna try to decipher what you have posted for myself. Please correct me if I am wrong.


    "TypeName" refers to a given type of object or class. I assume this is setting "texty" as a variable which would need to be defined... I am guessing something like "dim texty as object" (or something like that?).

    Since texty is set as a textbox after beginning to "For Each" with texty, I don't see how that can function.

    "For Each" tells it to check the entire userform for all objects and do the action/code defined after "Then" on all objects that match whatever "texty" is defined as (textbox).

    Next tells it to continue the check and move on to the next object and repeat.


    I believe the code needed to set "texty" as upper case is "texty.value = UCase(texty)"

    I will assume again that the msgbox has nothing to do with what I want.

    So I will now try this.

    Please Login or Register  to view this content.
    This throws an error on the very first line so I will define "texty" as a thing with "dim texty as object".

    After defining "texty" as an object, it throws "object required" at me and highlights the second line, presumably because "texty" doesn't actually exist as it hasn't been defined as a text box until after we are already trying to use it.

    From here I have no clue where to go.
    Last edited by IMM Tech; 02-27-2018 at 02:50 PM.

  8. #8
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Re: Set *everything* on userform to force caps?

    Hi IMM Tech

    Apologies - I gave a bad example. It shows how the structure works, but now how to use it to solve your issue.

    The code below has just been tested with one userform (called UserForm1 in this instance - that bit's important), 3 textbuttons and a command button.
    When the command button is clicked, the textboxes become uppercase.
    Please Login or Register  to view this content.
    HTH

    DominicB

  9. #9
    Registered User
    Join Date
    02-16-2018
    Location
    WI
    MS-Off Ver
    2016
    Posts
    56

    Re: Set *everything* on userform to force caps?

    Works perfectly, thanks.

    I don't know why I missed the stupid userform1 thing. Bad day perhaps.

+ 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] Trim Special Chars & Small Caps and Return the Big Caps and Space only
    By Dahlia in forum Excel Formulas & Functions
    Replies: 25
    Last Post: 07-30-2017, 11:23 AM
  2. how to force all caps on input
    By Snookzit56 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 02-19-2016, 04:39 PM
  3. [SOLVED] Force userform to close
    By AndyE in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-24-2015, 09:01 PM
  4. Auto format time with : in Col A and Force Caps in Col D on Woksheet_change
    By Gingermuppet in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-27-2013, 05:22 AM
  5. [SOLVED] force all caps
    By vamedic11 in forum Excel General
    Replies: 12
    Last Post: 12-29-2011, 01:09 PM
  6. Force Entry on UserForm
    By raehippychick in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-20-2007, 11:33 AM
  7. Force Caps in a cell??
    By tagr in forum Excel General
    Replies: 3
    Last Post: 03-18-2006, 01:25 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