Call VBA-Funktion, die benutzerdefinierten Typ aus der Tabelle zurückgibt
Ich habe eine vba-Funktion, die einen benutzerdefinierten Datentyp zurückgibt, der wie folgt definiert ist:
Public Type stockValue
stock As String
value As Double
End Type
Meine Frage ist, wie ich damit umgehe, wenn ich die Funktion aus einer Tabellenzelle aufrufe. Angenommen, ich möchte, dass die Zelle das @ anzeigstock
Wert, ich habe versucht=function().stock
und es funktioniert nicht
Jede Hilfe wird geschätzt, danke!
Function getLowestPnl(strat As String, rank As Integer) As stockValue
Call Conecta_DB(conexao)
Set registros = New ADODB.Recordset
strSQL = "SELECT stock,sum([value]) FROM Reports.dbo.Entry WHERE idStrategy='" & strat & "' and idType=1 GROUP BY stock ORDER BY sum([value])"
'strSQL = "SELECT [finance],[sales],[management],[research],[administration] FROM [COS].[dbo].[Complementarity] WHERE [idCompany] =" & idCompany & " and [year]=" & year & " and [CEO]=1"
registros.Open strSQL, conexao, adOpenStatic, adLockOptimistic
parar = False
If Not registros.EOF Then
x = registros.GetRows()
i = 0
Do While parar <> True
If i = (rank - 1) Then
getLargestShortExp.stock = Trim(x(0, i))
getLargestShortExp.value = x(1, i)
parar = True
End If
i = i + 1
Loop
End If
registros.Close
getLowestPnl = ret
End Function