VBA Run-time error -214724809 (80070057)

crazyeyeschase

Board Regular
Joined
May 6, 2014
Messages
104
Office Version
  1. 365
Platform
  1. Windows
I have a macro that resizes all of the shapes within a sheet excluding one. When I run the macro it works fine however it pulls an error "VBA Run-time error -214724809 (80070057)"

This is the code

Code:
Sub Resize()

For Each shape In Sheets("Sheet1").Shapes
    If shape.Name = "RightArrow" Then
    Else:
    [COLOR=#ff0000]shape.Select[/COLOR]
    Selection.ShapeRange.ScaleWidth 1.1, msoFalse, msoScaleFromTopLeft
    Selection.ShapeRange.ScaleHeight 1.1, msoFalse, msoScaleFromTopLeft
    Selection.ShapeRange.IncrementLeft 10
    Selection.ShapeRange.IncrementTop 3
    End If
Next

End Sub

When i run the debug it comes back with "shape.select" highlighted.

The error also says
Method 'select' of object 'shape' failed

If i remove this line then the macro doesnt work correctley so im not sure what to do here.
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
If Sheet1 is not the Active sheet, you cannot select a shape on Sheet1.

Try this...

Code:
[COLOR=darkblue]Sub[/COLOR] Resize()
    [COLOR=darkblue]Dim[/COLOR] shp [COLOR=darkblue]As[/COLOR] Shape
    [COLOR=darkblue]For[/COLOR] [COLOR=darkblue]Each[/COLOR] shp [COLOR=darkblue]In[/COLOR] Sheets("Sheet1").Shapes
        [COLOR=darkblue]If[/COLOR] shp.Name <> "RightArrow" [COLOR=darkblue]Then[/COLOR]
            shp.ScaleWidth 1.1, msoFalse, msoScaleFromTopLeft
            shp.ScaleHeight 1.1, msoFalse, msoScaleFromTopLeft
            shp.IncrementLeft 10
            shp.IncrementTop 3
        [COLOR=darkblue]End[/COLOR] [COLOR=darkblue]If[/COLOR]
    [COLOR=darkblue]Next[/COLOR]
[COLOR=darkblue]End[/COLOR] [COLOR=darkblue]Sub[/COLOR]
 
Upvote 0

Forum statistics

Threads
1,217,020
Messages
6,134,060
Members
449,857
Latest member
caracal

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