+ Reply to Thread
Results 1 to 8 of 8

Select shape in active cell

  1. #1
    Registered User
    Join Date
    03-30-2014
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    7

    Select shape in active cell

    I am trying to select a shape in a cell and place a cell reference into the shape. I know the cell address, but do not know the shape reference. (The row that the cell and shape reside came from copying the row from another sheet and inserting it into the current sheet). I can not seem to come up with the correct code to accomplish this. Right now I have:

    Cells(r + 1, 48).Select
    ActiveCell.Shapes.Select
    ActiveShapes.Formula = "$AW:" & r + 1

    Where r+1 is the row where the line finally resides after insertion and "AW" is the column to the right of the cell where the shape resides.

    I have tried to put the cell reference into the shape at the location where it is copied from but the reference is not dynamic and I can not seem to get it to be. Another issue that will arise is that the rows in the new sheet will probably be sorted and I question if the cell reference will follow the shape's new location.

    Any help and or pointing me in the right direction would help.

    Thanks

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Select shape in active cell

    Hi, and welcome to the forum.

    One way

    Please Login or Register  to view this content.
    Last edited by Richard Buttrey; 03-30-2014 at 02:30 PM.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Registered User
    Join Date
    03-30-2014
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Select shape in active cell

    Thanks you for the response. This may put me on the right track. I am getting an access denied error in

    "shp.TextFrame2.TextRange.Characters.Text = c.Address" line. In the previous lines of code in the procedure, I unlock the sheet, so I would not think it is a protection issue.

    If it make any difference, the shape is a Right Triangle. (I am confused on the "TextFrame2" notation)

    If I will need to change all of the shapes because of sorting, will it be better to loop through all of the shapes on the sheet and find their location, changing all of the references to the cell to the right all at once? (not sure if I know how to do it, though)

    Kind of like this (which hangs on the 5th line with a Run-Time error of "The item with the specified name wasn't found"

    Dim Row As Integer
    Dim Shp As Shape
    For Each Shp In ActiveSheet.Shapes
    Shp.Select
    Row = Sheets("Main Bid").Shapes(Application.Caller).TopLeftCell.Row
    Selection.Formula = "=AW" & Row
    Next

    BTW - I hope I am being true to the forum rules.

    Thanks
    Last edited by Papa Newch; 03-30-2014 at 03:05 PM. Reason: Adding a suggested code

  4. #4
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Select shape in active cell

    Hi,

    See attached.The only difference is that the shape is located in C3 rather than your column AW.

    The 'TextFrame2' is simply the syntax to reference the object that contains text formatting for the specified shape.

    Hopefully you can map this onto your production workbook. If not upload your workbook.

  5. #5
    Registered User
    Join Date
    03-30-2014
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Select shape in active cell

    Thanks for all of your time!

    I am so sorry, but I can not figure where to get "The Attached"

  6. #6
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Select shape in active cell

    ....Oops! my fault. Forgot to attach it.

    Here it comes.....
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    03-30-2014
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Select shape in active cell

    Sorry, but I can not get this to work. I think I will need to go to a plan B.

    Thanks for all of your help on this. Very much appreciated.

  8. #8
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: Select shape in active cell

    Hi,

    Try the following routine to get information about the shape. Results will be in the 'Immediate Window' (CTRL G in the debugger). If the shape name is still unclear, move the shape temporarily to the left edge of the screen and try again. The 'Left' component will help you find the name of the shape. The shape name may also show up in the window in the upper left of the screen that show's cell addresses, when you 'right click' on the shape.
    Please Login or Register  to view this content.
    The following may help you rename a shape once you know it's original name from above:
    Please Login or Register  to view this content.
    The following may help you put text in the shape:
    Please Login or Register  to view this content.
    Lewis

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] A macro after setting onaction for a shape that will select the shape.
    By vonRobbo in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-20-2014, 11:34 PM
  2. VBA to change cell value when a shape object is double clicked or active
    By tantcu in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-06-2014, 02:31 PM
  3. Select a shape based on a cell value and update the shape when value changes
    By BigAl99 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-14-2013, 12:06 PM
  4. [SOLVED] Insert Excel Shape at Active Cell - Final help needed Please
    By PeterF in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 12-29-2012, 01:27 PM
  5. [SOLVED] Test if the active cell contains a shape
    By Frank & Pam Hayes in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-11-2005, 10:05 AM

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