Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Help with Case Please
Why am I getting an answer of 1 everytime? The function seems to be skipping
the Case programming. What do I need to do to fix this? Function TabeGECol(Level, Form) As Integer Dim ColNum As Integer ColNum = 1 Select Case Level Case Level = "L" ColNum = 2 Case Level = "E" ColNum = 10 Case Level = "M" ColNum = 18 Case Level = "D" ColNum = 26 Case Level = "A" ColNum = 34 End Select Select Case Form Case Form = 7 ColNum = ColNum + 0 Case Form = 8 ColNum = ColNum + 2 Case Form = 9 ColNum = ColNum + 4 Case Form = 10 ColNum = ColNum + 6 End Select TabeGECol = ColNum End Function |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Help with Case Please
Maybe you're not passing a nice Level value to the function?????
Or maybe you're passing a lower case letter???? Select Case ucase(Level) St@cy wrote: Why am I getting an answer of 1 everytime? The function seems to be skipping the Case programming. What do I need to do to fix this? Function TabeGECol(Level, Form) As Integer Dim ColNum As Integer ColNum = 1 Select Case Level Case Level = "L" ColNum = 2 Case Level = "E" ColNum = 10 Case Level = "M" ColNum = 18 Case Level = "D" ColNum = 26 Case Level = "A" ColNum = 34 End Select Select Case Form Case Form = 7 ColNum = ColNum + 0 Case Form = 8 ColNum = ColNum + 2 Case Form = 9 ColNum = ColNum + 4 Case Form = 10 ColNum = ColNum + 6 End Select TabeGECol = ColNum End Function -- Dave Peterson |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Help with Case Please
Try this:
Function TabeGECol(Level As String, Form As Integer) As Integer Dim ColNum As Integer ColNum = 1 Select Case Level Case "L" ColNum = 2 Case "E" ColNum = 10 Case "M" ColNum = 18 Case "D" ColNum = 26 Case "A" ColNum = 34 End Select Select Case Form Case 7 ColNum = ColNum + 0 Case 8 ColNum = ColNum + 2 Case 9 ColNum = ColNum + 4 Case 10 ColNum = ColNum + 6 End Select TabeGECol = ColNum End Function RBS "St@cy" wrote in message ... Why am I getting an answer of 1 everytime? The function seems to be skipping the Case programming. What do I need to do to fix this? Function TabeGECol(Level, Form) As Integer Dim ColNum As Integer ColNum = 1 Select Case Level Case Level = "L" ColNum = 2 Case Level = "E" ColNum = 10 Case Level = "M" ColNum = 18 Case Level = "D" ColNum = 26 Case Level = "A" ColNum = 34 End Select Select Case Form Case Form = 7 ColNum = ColNum + 0 Case Form = 8 ColNum = ColNum + 2 Case Form = 9 ColNum = ColNum + 4 Case Form = 10 ColNum = ColNum + 6 End Select TabeGECol = ColNum End Function |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Help with Case Please
Function TabeGECol(Level, Form) As Integer
Dim ColNum As Integer ColNum = 1 Select Case Level Case "L" ColNum = 2 Case "E" ColNum = 10 Case "M" ColNum = 18 Case "D" ColNum = 26 Case "A" ColNum = 34 End Select Select Case Form Case 7 ColNum = ColNum + 0 Case 8 ColNum = ColNum + 2 Case 9 ColNum = ColNum + 4 Case 10 ColNum = ColNum + 6 End Select TabeGECol = ColNum End Function -- Gary''s Student - gsnu200715 |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Help with Case Please
In general macro comparisons are case sensitive,
and worksheet formulas are case in-sensitive. See http://www.mvps.org/dmcritchie/excel...tm#sensitivity Select Case UCase(Level) --- HTH, David McRitchie, Microsoft MVP - Excel My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm Search Page: http://www.mvps.org/dmcritchie/excel/search.htm "St@cy" wrote in message ... Why am I getting an answer of 1 everytime? The function seems to be skipping the Case programming. What do I need to do to fix this? Function TabeGECol(Level, Form) As Integer Dim ColNum As Integer ColNum = 1 Select Case Level Case Level = "L" ColNum = 2 Case Level = "E" ColNum = 10 Case Level = "M" ColNum = 18 Case Level = "D" ColNum = 26 Case Level = "A" ColNum = 34 End Select Select Case Form Case Form = 7 ColNum = ColNum + 0 Case Form = 8 ColNum = ColNum + 2 Case Form = 9 ColNum = ColNum + 4 Case Form = 10 ColNum = ColNum + 6 End Select TabeGECol = ColNum End Function |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
Help with Case Please
It probably has to do with the parameters you're passing in. Try this. Put
a Case Else statement as the last Case in each of your selects (a good practice anyway). You might try to put a Stop as the statement in the case else. Your code will probably stop there. You can then use the immediate window to find out what the value of Level is. "St@cy" wrote: Why am I getting an answer of 1 everytime? The function seems to be skipping the Case programming. What do I need to do to fix this? Function TabeGECol(Level, Form) As Integer Dim ColNum As Integer ColNum = 1 Select Case Level Case Level = "L" ColNum = 2 Case Level = "E" ColNum = 10 Case Level = "M" ColNum = 18 Case Level = "D" ColNum = 26 Case Level = "A" ColNum = 34 End Select Select Case Form Case Form = 7 ColNum = ColNum + 0 Case Form = 8 ColNum = ColNum + 2 Case Form = 9 ColNum = ColNum + 4 Case Form = 10 ColNum = ColNum + 6 End Select TabeGECol = ColNum End Function |
#7
Posted to microsoft.public.excel.programming
|
|||
|
|||
Help with Case Please
Thanks! That did it. ...so simiple
"Gary''s Student" wrote: Function TabeGECol(Level, Form) As Integer Dim ColNum As Integer ColNum = 1 Select Case Level Case "L" ColNum = 2 Case "E" ColNum = 10 Case "M" ColNum = 18 Case "D" ColNum = 26 Case "A" ColNum = 34 End Select Select Case Form Case 7 ColNum = ColNum + 0 Case 8 ColNum = ColNum + 2 Case 9 ColNum = ColNum + 4 Case 10 ColNum = ColNum + 6 End Select TabeGECol = ColNum End Function -- Gary''s Student - gsnu200715 |
#8
Posted to microsoft.public.excel.programming
|
|||
|
|||
Help with Case Please
Just something different...
Function TabeGECol(Level, Form) As Integer Dim ColNum As Long ColNum = 1 'Default Select Case UCase(Level) Case "L", "E", "M", "D", "A" ' { 2, 10, 18, 26, 34} ColNum = 429295654 Mod Asc(UCase(Level)) End Select Select Case Form Case 7, 8, 9, 10 ColNum = ColNum + 2 * Form - 14 End Select TabeGECol = ColNum End Function -- HTH :) Dana DeLouis Windows XP & Office 2007 "St@cy" wrote in message ... Why am I getting an answer of 1 everytime? The function seems to be skipping the Case programming. What do I need to do to fix this? Function TabeGECol(Level, Form) As Integer Dim ColNum As Integer ColNum = 1 Select Case Level Case Level = "L" ColNum = 2 Case Level = "E" ColNum = 10 Case Level = "M" ColNum = 18 Case Level = "D" ColNum = 26 Case Level = "A" ColNum = 34 End Select Select Case Form Case Form = 7 ColNum = ColNum + 0 Case Form = 8 ColNum = ColNum + 2 Case Form = 9 ColNum = ColNum + 4 Case Form = 10 ColNum = ColNum + 6 End Select TabeGECol = ColNum End Function |
#9
Posted to microsoft.public.excel.programming
|
|||
|
|||
Help with Case Please
You are very welcome
-- Gary''s Student - gsnu200715 "St@cy" wrote: Thanks! That did it. ...so simiple "Gary''s Student" wrote: Function TabeGECol(Level, Form) As Integer Dim ColNum As Integer ColNum = 1 Select Case Level Case "L" ColNum = 2 Case "E" ColNum = 10 Case "M" ColNum = 18 Case "D" ColNum = 26 Case "A" ColNum = 34 End Select Select Case Form Case 7 ColNum = ColNum + 0 Case 8 ColNum = ColNum + 2 Case 9 ColNum = ColNum + 4 Case 10 ColNum = ColNum + 6 End Select TabeGECol = ColNum End Function -- Gary''s Student - gsnu200715 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
change data of entire column from small case to upper case | Excel Worksheet Functions | |||
Changing multiple cell text from lower case to upper case | Excel Discussion (Misc queries) | |||
How to change mixed case to upper case in Excel for all cells | Excel Discussion (Misc queries) | |||
Change the text from lower case to upper case in an Excel work boo | Excel Discussion (Misc queries) | |||
How do I change existing text from lower case to upper case | Excel Discussion (Misc queries) |