Solved

Is It Possible To Have A Shape Move Down A Sheet As A Table's Dynamic Range Expands?

Posted on 2013-06-12
5
252 Views
Last Modified: 2013-06-12
I have a table in a spreadsheet. When you get to the last cell in the table, if you press 'tab' a new row is added to the table. I also have a shape below the table. As the table range increases, it eventually overtakes the shape and either is hidden by it or hides the shape, depending on the level of the layer. I have the shape set to be moved with cells, but unfortunately the table doesn't create a new row when it expands it's range - it just takes the next existing row and adds it to the table. I have googled this and can't find anything, which is weird because I feel like this isn't that outlandish of a request. I just want my shape to move down with my table so that they maintain the original layout as the table expands.  Is this possible?
0
Comment
Question by:Animaldrummer04
  • 3
  • 2
5 Comments
 
LVL 92

Accepted Solution

by:
Patrick Matthews earned 250 total points
ID: 39242040
Try using this in the sheet module for the worksheet you need "watched":


Private Sub Worksheet_Change(ByVal Target As Range)
    
    Dim tbl As ListObject
    Dim shp As Shape
    Dim TblLastRow As Long
    
    Set tbl = Me.ListObjects("MyTable") 'rename as needed
    Set shp = Me.Shapes("Fred") 'rename as needed
    
    With tbl
        TblLastRow = .Range.Rows(.Range.Rows.Count).Row
    End With
    
    With Me.Rows(TblLastRow)
        shp.Top = .Top + .Height + 10 'or use more or less space to separate them
    End With
    
End Sub

Open in new window

0
 

Author Comment

by:Animaldrummer04
ID: 39242408
Thank you for that, that does work. However, is there a way to get the shape to move down as soon as the new row is created? As it is written, the code uses the last row with data in the table, so when a new row is created the table doesn't move until something is typed into that row. And is the only way to do this with VBA/macro?
0
 

Author Comment

by:Animaldrummer04
ID: 39242425
I attached the workbook i tested the solution out with, if that's helpful.
test.xlsm
0
 
LVL 92

Expert Comment

by:Patrick Matthews
ID: 39242512
>>is there a way to get the shape to move down as soon as the new row is created?

No

>>And is the only way to do this with VBA/macro?

Yes
0
 

Author Closing Comment

by:Animaldrummer04
ID: 39242708
Thanks! Not exactly what i was looking for, but it seems as if what i was looking for is impossible.
0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Using Word 2013, I was experiencing some incredible lag when typing.  Here's what worked for me....
In this article we discuss how to recover the missing Outlook 2011 for Mac data like Emails and Contacts manually.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question