VBA to delete specific objects in worksheet

traub86

New Member
Joined
Nov 10, 2017
Messages
26
:confused:I am having trouble creating VBA to delete specific objects in a worksheet before I copy that worksheet to a new workbook. I have several macro buttons and signature blocks in worksheet1 and when I click my export button I need the macro buttons to go away but the signature blocks to stay there. I tried going into Advanced settings and unchecking "Cut, Copy, and sort inserted objects with their parent cells" but the signature blocks go away as well. Any help would be greatly appreciated.:confused:
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
That didn't work. I played around with it for a bit to see if I could uncheck the "Cut, Copy, and sort inserted objects with their parent cells" in advanced options but it doesn't bring the signature blocks over. Do you think I could forego the signature blocks in the initial sheet and then add them in the destination sheet within the VBA code?
 
Upvote 0
Here's what I have and am trying to insert 8 signature lines in 2 rows across 4 columns over range A42:AB55:
Code:
Sub ExportToMasterFileChalk5()
    
    Workbooks("JMPI MANIFEST.xlsm").Sheets("Chalk 5").Copy before:=Workbooks("DO NOT DELETE_MASTER JMPI MANIFEST.xlsm").Sheets(1)
    Workbooks("DO NOT DELETE_MASTER JMPI MANIFEST.xlsm").Sheets(1).Name = Format(Date, "DDMMMYYYY") + " Chalk 5"
End Sub
 
Upvote 0
My understanding is that you are trying to remove command button(s). Is it an activeX or form control? Doesn't really matter. Use the following code to loop through and identify the buttons and type of buttons that you want to remove. Then remove (comment out) the message box and use the code to delete the button(s) adjusting the type as necessary. Just remove the 1st character from each line of the code that deletes the button (ie. that part of the code has been commented out). HTH. Dave
Code:
Sub RemoveButton()
Dim Sh As Shape
With Sheets("Sheet1") 'adjust to suit
For Each Sh In .Shapes
'type 12 activex command button
'type 8 form command button
MsgBox Sh.Name & " Type# " & Sh.Type
'If Sh.Type = 8 Then 'remove form button
'Sh.Delete
'End If
Next Sh
End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,066
Messages
6,122,948
Members
449,095
Latest member
nmaske

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