PDA

View Full Version : Syntax error assistance required



Aussiebear
07-31-2025, 07:01 PM
I have the following code within a module which keeps throwing up a syntax error 'wrong number of arguments or invalid property"


For i = 2 to lastRow
ip=Trim(ws.Source.Cells(i, "C").Value)
Dim parts() as String
parts = Split(ip, ".")
If UBound(parts) >=2 Then
ipPrefix = parts(0) & "." & parts(1) & "." & parts(2)
Else
ipPrefix = ip 'fallback if not a valid IP
End If
If Not ip.Dict.exists(ipPrefix) Then
Set rowList = New Collection
ipDict (ipPrefix) = rowList
End If
ipDict(ipPrefix).add 1
Next i


How do I fix this issue?

DocAElstein
08-01-2025, 03:20 AM
Hi
I may be talking rubbish or being too naïvely thinking just about Scripting.Dictionary stuff, but without seeing the rest of the coding, it seems a bit strange to me, just from that snippet, that you have a
If Not ip.Dict.exists(ipPrefix) Then

, and there after a
ipDict (ipPrefix) = rowList


Maybe that would not look so strange if I saw the rest of the coding

Alan

Paul_Hossler
08-01-2025, 05:30 AM
Since rowList is an Object, maybe you need



Set ipDict (ipPrefix) = rowList



??

Aussiebear
08-01-2025, 05:41 AM
Thank you Paul that worked for me.

jindon
08-02-2025, 03:17 AM
Or


If Not ipDict.exists(ipPrefix) Then
ipDict.Add ipPrefix, New Collection
End If