View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Leith Ross[_648_] Leith Ross[_648_] is offline
external usenet poster
 
Posts: 1
Default Function returning null value instead of string value


Hello Shivboy

Try using a Select Case statement in place of the nested If ElseI
statements..

Code
-------------------

Function convertDiv(oDiv As String) As Strin
Dim wDiv, oDivID As Strin
wDiv = oDi
Select Case wDi
Case Is = "A"
oDivID = "1
Case Is = "B"
oDivID = "2
Case Is = "C"
oDivID = "3
Case Is = "D"
oDivID = "4
Case Is = "E"
oDivID = "5
Case Is = "F"
oDivID = "6
Case Is = "G"
oDivID = "7
End Selec
convertDiv = oDivI
End Functio

-------------------

This makes your code easier to read and troubleshoot. Nested I
statements can become a real headache quickly. Not sure if you rename
your ComboBox to Combo1, but if you didn't you need to change it i
your code to ComboBox1

Sincerely
Leith Ros

--
Leith Ros
-----------------------------------------------------------------------
Leith Ross's Profile: http://www.excelforum.com/member.php...fo&userid=1846
View this thread: http://www.excelforum.com/showthread.php?threadid=55919