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.
I have another Select Case sub in my program that works perfectly, and has the same format as this one.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
Last edited by BCITgirl; 11-18-2010 at 11:33 PM.
Then the value of Range("ni") is none of the values you have listed.
Microsoft MVP - Excel
Entia non sunt multiplicanda sine necessitate
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-18-2010 at 11:48 PM.
Does it execute one of the "n=x" statements?
Microsoft MVP - Excel
Entia non sunt multiplicanda sine necessitate
Yes. Well, when I step into the sub it highlights the one its supposed to. I assume that means it executes it?
Solved, by another person in my class: Dim n as single, not integer
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks