Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

142
Views
For Next loop is always connecting to the last node in the previous collection

I am trying to create connectors between the nodes (circle shapes) in the previous "sector" and the nodes (circle shapes) in the currently created "sector."

WHAT WORKS: The connectors are being created, each of which end at each of the nodes within the currently created sector.

WHAT DOESNT WORK: The connectors all begin from the same node in the previous sector - specifically, the last one.

Here is the code for SECTOR 2 (the code for SECTOR 1 is exactly the same, except for the naming of course)


Sub Node_Gen_S02()
    Call RESTART
    
    Dim i As Integer
    For i = 1 To rndNodeAmount_S02
        
        NodePosVer_RND = WorksheetFunction.RandBetween(-15, 15)
        NodePosHor_RND = WorksheetFunction.RandBetween(-40, 40)
        
        Set SectorSheet = Worksheets(1)
        Set SectorNodes = SectorSheet.Shapes
        
        Set S02_Node = SectorNodes.AddShape(msoShapeOval, 485 + NodePosHor_RND, ((Map_Median + NodePosVer_RND) - (S02_Range_Ver / 2) + ((S02_Range_Ver / (rndNodeAmount_S02 + 1)) * i) + NodePosVer_RND), 15, 15)
        
        S02_Node.Name = ("Sector02_Node0" & i)
            With S02_Node.Fill
                .ForeColor.RGB = RGB(51, 204, 204)
                .Transparency = 1
                .TwoColorGradient msoGradientFromCenter, 1
                .GradientStops(2).Color = RGB(0, 0, 0)
                .GradientStops(2).Position = 0.5
            End With
            With S02_Node.Line
                .ForeColor.RGB = RGB(255, 80, 80)
            End With
        
        Debug.Print ("Node Name:" & S02_Node.Name)
        
        
        
        ' GENERATE NODE CONNECTIONS between S01 and S02 -----------------------------------------------------------
        Set Sector02_Node_Connect = SectorNodes.AddConnector(msoConnectorStraight, 0, 0, 100, 100)

        With Sector02_Node_Connect.ConnectorFormat
            .BeginConnect ConnectedShape:=S01_Node, ConnectionSite:=1
            .EndConnect ConnectedShape:=S02_Node, ConnectionSite:=1
        End With
        
        With Sector02_Node_Connect.Line
            .ForeColor.RGB = RGB(51, 204, 204)
            .Weight = 1
            .BeginArrowheadStyle = msoArrowheadOval
            .EndArrowheadStyle = msoArrowheadOval
        End With
        
        Sector02_Node_Connect.Name = "C_S01_S02_" & i
                
        Sector02_Node_Connect.RerouteConnections
    Next i
End Sub

Anyone have any idea why it is doing that? (i suspect it has something to do with the fore next loop and/or the object reference in the line connection always being the same, but dont know how to solve it)

about 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!