Ich baue eine udf, die eine andere innerhalb verwendet, aber ich erhielt einen Fehler "ByRef Argument fehlt" in einer Iterationsvariablen, ich habe diese Zeichenfolge "-60981- -: 54044, -60981 -: 54044, -60981 -: 53835, -60981 -: 53835, "und ich möchte doppelte Einträge entfernen, also möchte ich diese Zeichenfolge zurückbekommen" -60981 -: 54044, 60981 -: 53835,“hier ist die erste UDF, das ist, was ich in dem zweiten verwenden mag: ersten UDF: getJSONUDF innerhalb UDF funktioniert nicht (ByRef argument type missmatch)
Public Function getJSON(JSONObject As String, ObjectNumber As Integer, GetBack As Integer) As Variant
' 0 = object and property
' 1 = object
' 2 = property of object
Dim CompleteObject As String
Dim ObjectsInJSON As Integer
ObjectsInJSON = Len(JSONObject) - Len(Application.Substitute(JSONObject, ",", ""))
If ObjectNumber <= ObjectsInJSON Then
If ObjectNumber = 1 Then
CompleteObject = Left(JSONObject, Application.Find(",", JSONObject, 1) - 1)
Else
CompleteObject = Application.Substitute(Mid(JSONObject, FindN(",",JSONObject, 1, ObjectNumber - 1) + 1, FindN(",", JSONObject, 1, ObjectNumber) - FindN(",", JSONObject, 1, ObjectNumber - 1)), ",", "")
End If
Select Case GetBack
Case Is = 0
getJSON = CompleteObject
Case Is = 1
getJSON = Left(CompleteObject, Application.Find(":", CompleteObject, 1) - 1)
Case Is = 2
getJSON = Right(CompleteObject, Len(CompleteObject) - Application.Find(":", CompleteObject, 1))
End Select
Else
getJSON = CVErr(xlErrNA)
End If
End Function
zweiter UDF GetUniqueTrailers
Public Function GetUniqueTrailers(JSON As String) As String
Dim i, TrailersCounter As Integer
TrailersCounter = Len(JSON) - Len(Application.Substitute(JSON, ",", ""))
Dim ArrayOfTrailers() As String
For i = 1 To TrailersCounter
'here below occurs this error, in the i variable
If IsError(Application.VLookup(getJSON(JSON, i, 0), ArrayOfTrailers, 1, False)) Then
ReDim Preserve ArrayOfTrailers(i)
ArrayOfTrailers(i) = getJSON(JSONstring, i, 0)
Next i
'convert array to text
For i = 1 To UBound(ArrayOfTrailers)
GetUniqueTrailers = getuniquetraileres & ArrayOfTrailers(i) & ","
Next i
End Function