Deleting an Autoshape with VBA in Excel 2003

stirlingmw

Board Regular
Joined
Feb 18, 2013
Messages
75
I have the following code attached to a commandbutton on a sheet which clears the content of a selected cell and if an autoshape is present this is deleted too.
My problem is when I designed the spreadsheet at home I was running Office 2013, but at work where I use the spreadsheet they run Office 2003 and this part of the code does not seem to work, any ideas??
Private Sub ClearSelectionFill()
Dim sh As Shape

Selection.Interior.Color = xlNone
Selection.ClearContents
For Each sh In ActiveSheet.Shapes
If Not Intersect(Selection, sh.TopLeftCell) Is Nothing Then
sh.Delete
End If
Next sh
End Sub
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
Hi stirlingmw,

The code you posted should work fine in either version of Excel. In addition I tested it in 2003 and it worked without error.

What kind of error are you getting?

Damon
 
Upvote 0

Forum statistics

Threads
1,224,249
Messages
6,177,417
Members
452,774
Latest member
Macca1962

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