• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

How to use curved connectors in excel vba which connects 2 cells by matching the strings in the cell

archit013

New Member
Code:
Sub AddCanvasConnector()
    Dim wksNew As Worksheet
    Dim shpCanvas As Shape
    Set wksNew = Worksheets.Add
    'Add drawing canvas to new worksheet
    Set shpCanvas = wksNew.Shapes.AddCanvas( _
        Left:=150, Top:=150, Width:=200, Height:=300)
    'Add connector to the drawing canvas
    shpCanvas.CanvasItems.AddConnector _
        Type:=msoConnectorStraight, BeginX:=150, _
        BeginY:=150, EndX:=200, EndY:=200
End Sub



Hi,
I want to connect two cells using curved connectors by matching the string present in both cells.
As I know curves can be created using above code.



But, How can I connect two cells by matching the values inside it and NOT by fixing coordinate axes.

I have attached the sample file for which I need help in writing macro.


Thanks
Archit

Mod Edit: Thread moved to appropriate section
 

Attachments

  • Curved Connector.xlsm
    8.9 KB · Views: 8
Last edited by a moderator:
@archit013
Test this ..
You gotta find cells 'D10' & 'F4' and 'G14' & 'J21' yourself.
Code:
Sub do_it()
    With Sheets(1)
        l = .Range("D10").Left
        t = .Range("D10").Top + .Range("D10").Height / 2
        w = .Range("F4").Left
        h = .Range("F4").Top + .Range("F4").Height / 2
        With .Shapes.AddConnector(msoConnectorCurve, l, t, w, h)
            .Line.Weight = 1
            .Line.ForeColor.RGB = RGB(255, 0, 0)
            .Line.DashStyle = msoLineSolid
        End With
        l = .Range("G14").Left
        t = .Range("G14").Top + .Range("G14").Height / 2
        w = .Range("J21").Left
        h = .Range("J21").Top + .Range("J21").Height / 2
        With .Shapes.AddConnector(msoConnectorCurve, l, t, w, h)
            .Line.Weight = 1
            .Line.ForeColor.RGB = RGB(255, 0, 0)
            .Line.DashStyle = msoLineSolid
        End With
    End With
End Sub
 
Back
Top