+ Reply to Thread
Results 1 to 9 of 9

Select Case

  1. #1
    Forum Contributor Rick_Stanich's Avatar
    Join Date
    11-21-2005
    Location
    Ladson SC
    MS-Off Ver
    Office365
    Posts
    1,192

    Select Case

    I don't see what I am doing wrong in this code using "Select Case". When activated and the correct string is entered I should get a msgbox pop up.
    Please Login or Register  to view this content.
    Last edited by Rick_Stanich; 10-16-2008 at 10:19 AM.
    Regards

    Rick
    Win10, Office 365

  2. #2
    Forum Contributor Stuie's Avatar
    Join Date
    09-17-2006
    Location
    Suffolk, UK
    MS-Off Ver
    Excel 2003/2007
    Posts
    432
    Hi Rick_Stanich,

    When you say Case 1 that is checking the value entered into sLogin and saying if it is 1 then do the code in this block.

    same as Case 2, Case 3, etc...

    change it to this.

    Please Login or Register  to view this content.
    and on Case 5 change the 5 to the string your checking for
    There are only 10 types of people in the world:
    Those who understand binary, and those who don't!

  3. #3
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,485
    Your code logic does not make sense.

    For the inner test of Inputted value you would need to convert the string value to a number before the case tests will work,
    Please Login or Register  to view this content.
    But if you enter 1 the first case test will be true so this code is executed.
    Please Login or Register  to view this content.
    Your problem now is that we already know sLogin contains "1" so it can not possible contain "RS61".
    Cheers
    Andy
    www.andypope.info

  4. #4
    Forum Contributor Rick_Stanich's Avatar
    Join Date
    11-21-2005
    Location
    Ladson SC
    MS-Off Ver
    Office365
    Posts
    1,192
    I see, I misunderstood what "Case 1" represented. I thought it meant "Case 1" as the first event and "Case 2" as the second and so on.

    Thanks!

  5. #5
    Forum Contributor Stuie's Avatar
    Join Date
    09-17-2006
    Location
    Suffolk, UK
    MS-Off Ver
    Excel 2003/2007
    Posts
    432
    Yea no problem, easy mistake to make really

  6. #6
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    You don't need the If to test for blank entry statement either
    Please Login or Register  to view this content.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  7. #7
    Forum Contributor Rick_Stanich's Avatar
    Join Date
    11-21-2005
    Location
    Ladson SC
    MS-Off Ver
    Office365
    Posts
    1,192
    One more question. :D

    I now display a msgbox when the Case is true, how do I capture when it is not true? (and show a msgbox).

    HAHA

    You answered my question before I posted, how astute!

  8. #8
    Forum Contributor Rick_Stanich's Avatar
    Join Date
    11-21-2005
    Location
    Ladson SC
    MS-Off Ver
    Office365
    Posts
    1,192
    Case closed!

    hehe

    I kill me!

  9. #9
    Forum Contributor Stuie's Avatar
    Join Date
    09-17-2006
    Location
    Suffolk, UK
    MS-Off Ver
    Excel 2003/2007
    Posts
    432
    not sure exactly what you mean do you mean to check if it is not a certain value like is not RS61.

    can you explain a little more??

    EDIT: Lol i was too late

+ 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. Select Case Error Handler?
    By hutch@edge.net in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-17-2008, 03:29 PM
  2. Numbers to Text
    By sachinattri in forum Excel General
    Replies: 6
    Last Post: 06-15-2008, 03:07 AM
  3. Coding in visual basic
    By jexy in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 02-06-2007, 08:01 AM
  4. VBA code - color format routine
    By xlwho in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-06-2006, 05:10 AM
  5. type mismatch
    By Mikeyhend in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-16-2006, 01:17 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