+ Reply to Thread
Results 1 to 4 of 4

Any way to capture x,y coordinates of a given cell?

  1. #1
    Registered User
    Join Date
    12-30-2008
    Location
    Vermont, USA
    MS-Off Ver
    Excel 2003
    Posts
    64

    Any way to capture x,y coordinates of a given cell?

    Hi all-
    I am trying to write some VBA that will allow me to draw an autoshape arrow linking one cell to another using...
    .AddLine([begin x], [begin y], [end x], [end y])

    I have a grid of cells that covers the array B2:BI41 (40 rows X 60 columns) that is empty except for 7 cells which have a letter in them (a, b, c d, e, f, or g). These cells will move all around the grid. I currently have x and y "axes" along the top and left side of this grid, respectively, but they are not very useful-- simply 1 2 3 4 5 .... -- I can obviously not use these as x , y coordinates for a line.

    What I would like is EITHER some way to dynamically obtain the x-y coordinates for a given cell OR dynamically create x and y axis values which I could in turn use in the .AddLine function above. By dynamically (this is the key here!), I mean that even if column widths/row heights are changed, I will still get accurate x-y coordinates for the center of that cell (or at least a good approximation).

    So, for instance if "b" is in cell F19 and "e" is in cell AG38 and I want to draw an arrow from "b" to "e".... ?

    Hope this makes sense! I am a complete caveman with VBA, by the way. Thanks a lot.

    NOTE that I am NOT making a chart-- this is literally a grid of cells (basically, a map)

  2. #2
    Forum Contributor
    Join Date
    04-21-2007
    Location
    Lima, Peru
    MS-Off Ver
    2000, 2007, 2010
    Posts
    674

    Re: Any way to capture x,y coordinates of a given cell?

    Hi

    Whilst I am not sure this is exactly what you need I hope it will give you an idea.

    Regards

    Jeff
    Attached Files Attached Files

  3. #3
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Any way to capture x,y coordinates of a given cell?

    This might help you get started:
    Please Login or Register  to view this content.
    Entia non sunt multiplicanda sine necessitate

  4. #4
    Registered User
    Join Date
    12-30-2008
    Location
    Vermont, USA
    MS-Off Ver
    Excel 2003
    Posts
    64

    Re: Any way to capture x,y coordinates of a given cell?

    Jeff and Shg:
    I will give these a try tomorrow and will mark the post as solved then -- thanks very much to both of you!

+ 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