+ Reply to Thread
Results 1 to 8 of 8

Determining Any Uppercase Letter

  1. #1
    Registered User
    Join Date
    03-31-2009
    Location
    Auburn Alabama
    MS-Off Ver
    Microsoft Office Excel 2007 (Windows)
    Posts
    99

    Thumbs up Determining Any Uppercase Letter

    Hello,

    My question is about determining whether or not a particular letter is uppercase.

    I've written code that reads from a text file one character at a time. And I know that the following determines if each character is equal to the letter "a".

    Please Login or Register  to view this content.
    But I want to code an If statement that tells if the character is any uppercase letter. Like "A", "B", "C", etc. I know I could do the following:

    Please Login or Register  to view this content.
    But that seems like a lot of unnecessary typing. Could I possibly use a wildcard character and a VBA type of UCase to accomplish the task?

    If so, how would I code that?

    Thanks for any and all help!
    Last edited by CrazyFileMaker; 04-22-2009 at 09:03 PM.

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

    Re: Determining Any Uppercase Letter

    Hello CrazyFileMaker,

    This will test if the character is a capital.
    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!)

  3. #3
    Registered User
    Join Date
    04-22-2009
    Location
    Magherafelt, Ireland
    MS-Off Ver
    Excel 2003
    Posts
    1

    Re: Determining Any Uppercase Letter

    depending on numeric value in cell A1 can I fill that number of cells across with a colour

  4. #4
    Valued Forum Contributor squiggler47's Avatar
    Join Date
    02-17-2009
    Location
    Littleborough, UK
    MS-Off Ver
    Excel 3.0 to 2007+2010! (couldnt get 2.1 working)
    Posts
    1,013

    Re: Determining Any Uppercase Letter

    or the classic way

    IF Character>="A" AND Character <="Z" THEN

  5. #5
    Registered User
    Join Date
    03-31-2009
    Location
    Auburn Alabama
    MS-Off Ver
    Microsoft Office Excel 2007 (Windows)
    Posts
    99

    Re: Determining Any Uppercase Letter

    Thanks Squiggler! That's perfect for my needs.

    I changed my code to what I think you meant:
    Please Login or Register  to view this content.

    Just out of curiosity though, could you or someone explain to me why my original way wasn't working.

    If Character is a capital M, then the following code functions correctly:
    Please Login or Register  to view this content.
    But If Character is any capital letter, the following does not work:
    Please Login or Register  to view this content.
    I've never used a wildcard character before... Is the problem with the brackets and the asterix? Did I not assign the wildcard character correctly?"

    Again, thanks for any and all help!
    Last edited by CrazyFileMaker; 04-22-2009 at 08:25 PM.

  6. #6
    Valued Forum Contributor squiggler47's Avatar
    Join Date
    02-17-2009
    Location
    Littleborough, UK
    MS-Off Ver
    Excel 3.0 to 2007+2010! (couldnt get 2.1 working)
    Posts
    1,013

    Re: Determining Any Uppercase Letter

    Please Login or Register  to view this content.
    the true is uneccessary becase Like "[A-Z]" returns true/false and if already checks true false, so your statement makes if do
    IF (Like "[A-Z]"=TRUE)=TRUE THEN

    Please Login or Register  to view this content.
    AnyLowerCaseLetter is a string not an expression so you are comparing "[*]" not a wild card, will only work in like statement!!!!

    see my first reply for the simple way to test for a capital letter!
    Last edited by squiggler47; 04-22-2009 at 08:37 PM.

  7. #7
    Registered User
    Join Date
    03-31-2009
    Location
    Auburn Alabama
    MS-Off Ver
    Microsoft Office Excel 2007 (Windows)
    Posts
    99

    Re: Determining Any Uppercase Letter

    Squiggler,

    The way it was posted originally:
    Please Login or Register  to view this content.
    Didn't work. I got "Compile error: Expected: expression"
    And the word "Like" was high-lighted

    So I played around with that and came up with:
    Please Login or Register  to view this content.
    What was originally meant must've been:
    Please Login or Register  to view this content.
    I see that now. Thanks for the correction.

    The "greater/less-than-or-equal-to" way also proved a very simple solution.

    Playing around I also found the following works as well:
    Please Login or Register  to view this content.
    Still, I like your way better.

    Sorry for the confusion and, again, thanks for the help! Got it working nicely now.
    Last edited by CrazyFileMaker; 04-22-2009 at 09:02 PM.

  8. #8
    Valued Forum Contributor squiggler47's Avatar
    Join Date
    02-17-2009
    Location
    Littleborough, UK
    MS-Off Ver
    Excel 3.0 to 2007+2010! (couldnt get 2.1 working)
    Posts
    1,013

    Re: Determining Any Uppercase Letter

    Yes, and your other bit

    UCASE("[?]") doesnt work because there are no letters that can be changed to upper case!!

    UCASE("[abc]") changes it to "[ABC]"

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

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