Q
qerj
I have a procedure run by a commandbutton on 1 worksheet that copies
another worksheet to a 3rd worksheet. The procedure then is supposed
to delete the commandbuttons on the newly copied worksheet. It
deletes the 1st one ok but ends in a 1004 error when trying to delete
the 2nd button. What am I doning wrong...thx
here is the code for the deletion of the objects...
Option Compare Text
Dim strMainWks As String
Dim strTmpWks As String
Dim wsCurWks As Worksheet
Dim rSortRange As Range
Dim rMyRange As Range
Dim rMyCell As Range
Dim rMyDeletion As Range
Sub deletebtns_Click()
Dim wsCurWks As Worksheet
Dim Obj As OLEObject
Set wsCurWks = ActiveSheet
For Each Obj In ActiveSheet.OLEObjects
If InStr(1, Obj.ProgId, "CommandButton") <> 0 Then
'MsgBox Obj.ProgId
Obj.Delete
End If
Next Obj
End Sub
another worksheet to a 3rd worksheet. The procedure then is supposed
to delete the commandbuttons on the newly copied worksheet. It
deletes the 1st one ok but ends in a 1004 error when trying to delete
the 2nd button. What am I doning wrong...thx
here is the code for the deletion of the objects...
Option Compare Text
Dim strMainWks As String
Dim strTmpWks As String
Dim wsCurWks As Worksheet
Dim rSortRange As Range
Dim rMyRange As Range
Dim rMyCell As Range
Dim rMyDeletion As Range
Sub deletebtns_Click()
Dim wsCurWks As Worksheet
Dim Obj As OLEObject
Set wsCurWks = ActiveSheet
For Each Obj In ActiveSheet.OLEObjects
If InStr(1, Obj.ProgId, "CommandButton") <> 0 Then
'MsgBox Obj.ProgId
Obj.Delete
End If
Next Obj
End Sub