Drawn Objects Q

S

seanryanie

I have the code below which deletes "Objects" in my sheet, my problem is that it deletes a cell in Column A and moves all cells up one space, I don't know why this is occurring

When I try and select "Objects" within Find-Go to Special-Objects, it says there is none to be found and that is before I run the code below

Hope someone can advise

Thanks


Sub ClearMacroButtons()
Application.ScreenUpdating = False

Sheets("Figures").Visible = True
Sheets("Figures").Select
ActiveSheet.Unprotect Password:="1234"
ActiveSheet.DrawingObjects.Select
Selection.Delete
Range("A1").Select
ActiveSheet.Protect Password:="1234"

End Sub
 
A

Abhijeet Gudur

Try below and see what happens ..

Option Explicit

Sub FormatAllCallouts()
Dim oShp As Shape
Dim oCF As CalloutFormat
On Error GoTo MyExit

Sheets("Figures").Visible = True
Sheets("Figures").Select
ActiveSheet.Unprotect Password:="1234"
For Each oShp In ActiveSheet.Shapes
oShp.Select
Selection.Delete
Next
Range("A1").Select
ActiveSheet.Protect Password:="1234"

Exit Sub
MyExit:
MsgBox "No shapes found!!""
End Sub
 
S

seanryanie

Try below and see what happens ..



Option Explicit



Sub FormatAllCallouts()

Dim oShp As Shape

Dim oCF As CalloutFormat

On Error GoTo MyExit



Sheets("Figures").Visible = True

Sheets("Figures").Select

ActiveSheet.Unprotect Password:="1234"

For Each oShp In ActiveSheet.Shapes

oShp.Select

Selection.Delete

Next

Range("A1").Select

ActiveSheet.Protect Password:="1234"



Exit Sub

MyExit:

MsgBox "No shapes found!!""

End Sub

Your code returns "no shapes found", but why then in my original code, if there is no objects found it deletes a cell in Column A and moves all cells up one space

My code is wrong, but I don't know why
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top