Vertical connector with specific lenght

Doflamingo

Board Regular
Joined
Apr 16, 2019
Messages
238
Dear All,

Here is the code for horizontal connector for an active cell where the connector displays at the middle of that cell. Its lenght is half of the previous cell + current cell + half of the next cell.
@Dante gave me kindly those lines of code.

Code:
l = (ActiveCell.Offset(0, -1).Left + ActiveCell.Left) / 2
    r = (ActiveCell.Offset(0, 1).Left + ActiveCell.Offset(0, 2).Left) / 2
    t = (ActiveCell.Top + ActiveCell.Offset(1, 0).Top) / 2
    Set con = ActiveSheet.Shapes.AddConnector(msoConnectorStraight, l, t, r, t)
        con.line.Weight = 1
        con.line.ForeColor.RGB = RGB(0, 0, 0)

Now I try to find, following the same line of code but for an Vertical connector that would go down 3 lines from the active cell

Any ideas ?Here is my code, but does not work

Code:
Sub con_vertical()
    l = (ActiveCell) / 2
    r = (ActiveCell.Top)
    t = (ActiveCell.Top + 3)
    Set con = ActiveSheet.Shapes.AddConnector(msoConnectorStraight, l, r, l, t)
        con.line.Weight = 1
        con.line.ForeColor.RGB = RGB(0, 0, 0)
End Sub
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
Does this do what you want?

Code:
Sub con_vertical()
    l = (ActiveCell.Offset(0, -1).Left + ActiveCell.Left) / 2
    t = (ActiveCell.Top + ActiveCell.Offset(1, 0).Top) / 2
    b = ActiveCell.Offset(4, 0).Top + (ActiveCell.Offset(4, 0).Height / 2)
    Set con = ActiveSheet.Shapes.AddConnector(msoConnectorStraight, l, t, l, b)
        con.Line.Weight = 1
        con.Line.ForeColor.RGB = RGB(0, 0, 0)
End Sub
 
Upvote 0
Hello @Domenic, Thanks for your answer :)

I've tried your code and it almost gave what I was looking for. Indeed it gives me a vertical connector, but not on the active cell. It displays always to any another cells of the sheet and with a different lenght at each time ....
 
Upvote 0
Can you please explain in words where exactly you want your vertical connector positioned?
 
Upvote 0
Sorry, but I don't download anything from the internet. If you can explain what you want in words, I'll try to help. Otherwise, someone else here on the Board may be willing to download and look at your sample workbook.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,171
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top