Results 1 to 6 of 6

Select Case code not returning correct statement

Threaded View

  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.

    Sub Roughness()
    Dim n As Integer
    
    Select Case Range("ni")
        Case 1
            n = 0.011
        Case 2
            n = 0.012
        Case 3
            n = 0.015
        Case 4
            n = 0.022
        Case 5
            n = 0.011
        Case 6
            n = 0.03
        Case 7
            n = 0.035
        Case 8
            n = 0.04
        Case 9
            n = 0.009
        Case 10
            n = 0.01
        Case 11
            n = 0.012
        Case 12
            n = 0.011
        Case 13
            n = 0.019
    End Select
    
    Range("nval").Value = n
    
    End Sub
    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.

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