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
248 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
Comment Utility
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
Comment Utility
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
Comment Utility
I attached the workbook i tested the solution out with, if that's helpful.
test.xlsm
0
 
LVL 92

Expert Comment

by:Patrick Matthews
Comment Utility
>>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
Comment Utility
Thanks! Not exactly what i was looking for, but it seems as if what i was looking for is impossible.
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Recently Microsoft released a brand new function called CONCAT. It's supposed to replace its predecessor CONCATENATE. But how does it work? And what's new? In this article, we take a closer look at all of this - we even included an exercise file for…
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 demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.

772 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

11 Experts available now in Live!

Get 1:1 Help Now