+ Reply to Thread
Results 1 to 5 of 5

Macro to create lines that connect cells

  1. #1
    Registered User
    Join Date
    12-13-2012
    Location
    Sydney
    MS-Off Ver
    2010
    Posts
    2

    Macro to create lines that connect cells

    I would like to create a macro that inserts vectors from the bottom of one cell to the top of another.

    I have found the below approach but it does not seem to work. can someone help me please?

    Sub insert_lines()

    start_x = 0
    start_y = 0
    end_x = 10
    end_y = 10

    Line = Sheet1.Shapes.AddLine(start_x, start_y, end_x, end_y)
    Line.Line.EndArrowheadStyle = MsoArrowheadStyle.msoArrowheadTriangle


    End Sub

  2. #2
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: Macro to create lines that connect cells

    attach a sample file with desired result
    If solved remember to mark Thread as solved

  3. #3
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,448

    Re: Macro to create lines that connect cells

    Hi 425349 and welcome to the forum,

    Location of cells in VBA only give the top and left coordinates. You then need their height and width to tell where they end. Here is an attached that puts an arrow on a named range of "Boxer" which you can define on your worksheet. This isn't great but should give you the basics to get that darn arrow where you want it.
    Attached Files Attached Files
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  4. #4
    Registered User
    Join Date
    12-13-2012
    Location
    Sydney
    MS-Off Ver
    2010
    Posts
    2

    Re: Macro to create lines that connect cells

    thank you.

  5. #5
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: Macro to create lines that connect cells

    Good code, but I think it's easier to use selected range like
    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1