Pestomania
Active Member
- Joined
- May 30, 2018
- Messages
- 332
- Office Version
- 365
- Platform
- 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>
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
Last edited: