PDA

View Full Version : Function returning multiple values



lutaz.dyha
09-24-2010, 08:04 AM
Hi...anyone can guide me how to write function in vba to return multiple values

the code's example is like this:

p/s: i want to return all type of count in this select case..

can anyone assist me???

thnk you...


Function returnSector(sector) As Integer

Select Case sector

Case "CLOSED FUND"

countCF = counCF + 1

Case "CONSTRUCTION"

countCF = counCF + 1

Case "CONSUMER PRODUCTS"

countCP = counCP + 1

Case "FINANCE"

countF = counF + 1

Case "HOTEL"

countH = countH + 1

Case "INDUSTRIAL PRODUCTS"

countIP = counIP + 1

Case "INFRASTRUCTURE PROJECT COS."

countIPC = countIPC + 1

Case "MINING"

countM = countM + 1

Case "PLANTATION"

countPL = countPL + 1

Case "PROPERTY"

countPR = countPR + 1

Case "TECHNOLOGY"

countT = countT + 1

Case "TRADING/SERVICES"

countTS = countTS + 1

End Select



End Function

Bob Phillips
09-24-2010, 08:18 AM
I don't understand your code, but this is the way



Public Sub Test()
Dim someValue

MsgBox returnSector("FINANCE", someValue)

MsgBox someValue
End Sub

Function returnSector(sector, anotherone) As Integer

returnSector = 27
anotherone = 99

End Function