Dynamically move linked pictures, to avoid overlaps / blank gaps between them

jorbarrientos

New Member
Joined
Feb 18, 2021
Messages
1
Office Version
  1. 365
Platform
  1. Windows
Hey everyone,

I was hoping someone could help with some ideas. I have an Excel report with multiple linked pictures, one after another in a vertical layout. Each of these linked pictures points to a named range, and each of these named ranges points to a specific pivot table. Some of these pivot tables row count (and therefore height) changes, depending on the filter value I select in a slicer that is connected to both pivot tables; however, in my final report, I need the linked pictures that reference these pivot tables to be exactly one below the other, with no overlaps, but no blank gaps between them. This has to update everytime I change my slicer value.

The problem right now is that everytime I select a new value in the slicer, if the linked picture at the top grows in height, it overlaps with the linked picture below; and viceversa, if the linked picture at the top shrinks in height, there is a huge white space between that picture and the linked picture below.

Is there a way to automate the behaviour I am looking for? Any help would be greatly appreciated!
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
Is this what you want

From this
resize shapes.jpg


To this
resize shapes2.jpg


If it is, amend this code to suit your needs
VBA Code:
Sub LoopPics()
    Dim shp As Shape, cel As Range
    For Each shp In ActiveSheet.Shapes
        Set cel = shp.TopLeftCell
        If cel.Column = 2 Then
            With shp
                .Left = cel.Left
                .Top = cel.Top
                .Height = cel.Height
            End With
        End If
    Next
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,883
Messages
6,175,168
Members
452,615
Latest member
bogeys2birdies

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top