title: VBA: How to center every single image in one excel sheet in their current cells
body: <p>The code below will center an image within a cell, given that you know both the name of the image and the cell that it is located in. Is anyone familiar with a dynamic loop that will search a single sheet for every image in that sheet and center every image in its current cell? If this isnt possible is there a way to change the code so that you can loop through a specific range? For example <code>A4:A10</code></p>
  <pre><code>    Sub CenterImages()
          With ActiveSheet.Shapes(&quot;Picture 1&quot;)
              .Top = Range(&quot;B1&quot;).Top + (Range(&quot;B1&quot;).Height - .Height) / 2
              .Left = Range(&quot;B1&quot;).Left + (Range(&quot;B1&quot;).Width - .Width) / 2
          End With
      End Sub
  
  </code></pre>