Resize One Pic

Pestomania

Active Member
Joined
May 30, 2018
Messages
295
Office Version
  1. 365
Platform
  1. Windows
Hi,

I have been using a vba code for a while, but I can't get it to work anymore. Not sure what I'm doing wrong.

The code should determine the last used cell in column "A". And then it will fill the height or width of the empty space. But the image height cannot be more than H and width cannot be more than W.

The sheets follow these parameters (example):

Last Cell in Column A: A8
Last used Column: T
Last used Row: 32 (this is standard on all sheets)

So the space to fill is from A9:S32

Any help is appreciated. Thank you

<code>
Code:
Dim T, L as double
Lastcolumnnumber = ActiveSheet.Cells(2, Columns.Count).End(xltoLeft).Column
Lastcolumnletter = split(cells(1, lastcolumnnumber).Address, "$")(1)
Lastrow =range("A" & rows.count).End(xlUp).Offset(1).Row
Top = Range("A" & lastrow).Top + 0.75

With ActiveSheet
   W=testright -1.5
   H=range("B" & lastrow & ":S32").Height - 1.5

   With .Range("B" & Rows.count).End(xlup).Offset(1)
      L=.Left
      T = .Top
   End with

   With Selection
      .Top = T + 0.75
      .Left = L
   End with


With Selection
   If .Height > H then
       Selection.ShapeRange.Height =H
   Else
   If .Width > W then
       Selection.ShapeRange.Width = W
   Else
       Exit sub
   End if
   End if
End with
End with
</code>
 
Last edited:

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.

Forum statistics

Threads
1,216,500
Messages
6,131,016
Members
449,615
Latest member
Nic0la

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