Consulting

Results 1 to 6 of 6

Thread: Syntax error assistance required

  1. #1
    Site Admin VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,503
    Location

    Syntax error assistance required

    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?
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  2. #2
    VBAX Regular DocAElstein's Avatar
    Joined
    Oct 2023
    Location
    Hof, Germany
    Posts
    14
    Location
    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
    Last edited by DocAElstein; 08-01-2025 at 03:31 AM.

  3. #3
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,891
    Location
    Since rowList is an Object, maybe you need

    Set ipDict (ipPrefix) = rowList
    

    ??
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  4. #4
    Site Admin VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,503
    Location
    Thank you Paul that worked for me.
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  5. #5
    VBAX Contributor
    Joined
    Jul 2005
    Posts
    196
    Location
    Or
        If Not ipDict.exists(ipPrefix) Then
            ipDict.Add ipPrefix, New Collection
        End If

  6. #6
    Site Admin VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,503
    Location
    Thank you Jindon.
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •