+ Reply to Thread
Results 1 to 6 of 6

Select Case code not returning correct statement

  1. #1
    Registered User
    Join Date
    11-17-2010
    Location
    Vancouver
    MS-Off Ver
    Excel 2003/2007
    Posts
    7

    Select Case code not returning correct statement

    This is my code which I use in conjunction with a drop-down list. The "ni" range is the output range for the drop-down box. The "n" in the case statements is the value I want associated with the "ni", and the "nval" is the output where the value for "n" goes. When I try to run this code, The value for "n" that is returned is 0. I am not very good at vba and therefore cannot find where my problem is. This is the code.

    Please Login or Register  to view this content.
    I have another Select Case sub in my program that works perfectly, and has the same format as this one.
    Last edited by BCITgirl; 11-19-2010 at 12:33 AM.

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Select Case code not returning correct statement

    Then the value of Range("ni") is none of the values you have listed.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Registered User
    Join Date
    11-17-2010
    Location
    Vancouver
    MS-Off Ver
    Excel 2003/2007
    Posts
    7

    Re: Select Case code not returning correct statement

    But when I step through the sub, it will stop at the appropriate case, go to end select, but when I check the range "nval" it has 0 in it. I have also changed "ni" to other arbritary cells, and directy input values into the cells, with the same results.
    Last edited by BCITgirl; 11-19-2010 at 12:48 AM.

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Select Case code not returning correct statement

    Does it execute one of the "n=x" statements?

  5. #5
    Registered User
    Join Date
    11-17-2010
    Location
    Vancouver
    MS-Off Ver
    Excel 2003/2007
    Posts
    7

    Re: Select Case code not returning correct statement

    Yes. Well, when I step into the sub it highlights the one its supposed to. I assume that means it executes it?

  6. #6
    Registered User
    Join Date
    11-17-2010
    Location
    Vancouver
    MS-Off Ver
    Excel 2003/2007
    Posts
    7

    Re: Select Case code not returning correct statement

    Solved, by another person in my class: Dim n as single, not integer

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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