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
249 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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

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....
Technology opened people to different means of presenting information, but PowerPoint remains to be above competition. Know why PPT still works today.
Learn how to make your own table of contents in Microsoft Word using paragraph styles and the automatic table of contents tool. We'll be using the paragraph styles in Word’s Home toolbar to help you create a table of contents. Type out your initial …
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.

910 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now