Resize the shape with ScaleWidth 1.5

haseft

Active Member
Joined
Jun 10, 2014
Messages
321
Hi!

The following works great.
But I want to resize the shape with ScaleWidth 1.5 befor copy it to new cell.
I get error.
Please help.


HTML:
Function ShapeAtActiveCell() As String
  Dim Sh As Shape
  For Each Sh In ActiveSheet.Shapes
    If Sh.TopLeftCell.Address = ActiveCell.Address Then
      ShapeAtActiveCell = Sh.Name
      Exit Function
    End If
  Next
End Function

'--------------
With Worksheets("Blad2")
  .ShapeRange.ScaleWidth 1.5 ' I want to resize/ScaleWidth 1.5 befor copy
  .Shapes(ShapeAtActiveCell).Copy
End With
With Worksheets("Blad2")
   .Paste Destination:=.Cells(j, "C")
End With
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
Try this. I've changed the ShapeAtActiveCell function to return a Shape object instead of a shape name.

Code:
Public Sub Test()
    
    Dim shp As Shape, j As Long
    
    j = 10
    With Worksheets("Blad2")
        Set shp = ShapeAtActiveCell
        If Not shp Is Nothing Then
            Set shp = shp.Duplicate
            shp.Top = .Cells(j, "C").Top
            shp.Left = .Cells(j, "C").Left
            shp.ScaleWidth 1.5, msoFalse
        End If
    End With

End Sub

Private Function ShapeAtActiveCell() As Shape
    
    Dim shp As Shape
    
    For Each shp In ActiveSheet.Shapes
        If Not Intersect(ActiveCell, Range(shp.TopLeftCell, shp.BottomRightCell)) Is Nothing Then
            Set ShapeAtActiveCell = shp
            Exit Function
        End If
    Next
    
End Function
 
Upvote 0
Solution

Forum statistics

Threads
1,223,888
Messages
6,175,219
Members
452,620
Latest member
dsubash

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