Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Copy sheet without copying buttons

Tags:

excel

vba

i am trying to make a character creator tool for a game. im almost done but i wanted to add a button the saves the character code looking like this

Sub Save_character()
Dim ws As Worksheet

Worksheets("character creator").Copy _
After:=ActiveWorkbook.Sheets("character creator")

Set ws = ActiveSheet

ws.Name = Range("b14")

End Sub

but i dont want this button to be added to the copied sheet. Any idea how i may do that?

thx in advence. a VBA/excel rookie

like image 334
Mulle9000 Avatar asked May 16 '16 21:05

Mulle9000


People also ask

How do I copy a sheet in Excel?

Copy a worksheet in the same workbookRight click on the worksheet tab and select Move or Copy. Select the Create a copy checkbox. Under Before sheet, select where you want to place the copy. Select OK.


2 Answers

There's a setting for this:

Application.CopyObjectsWithCells = False
'copy your sheet
Application.CopyObjectsWithCells = True 'reset

Same as: Options >> Advanced >> Cut, Copy and Sort inserted objects with their parent cells (uncheck)

like image 141
Tim Williams Avatar answered Oct 18 '22 05:10

Tim Williams


You can delete the button using

ws.Shapes("YourButtonName").Delete

like image 34
Chia Wei Avatar answered Oct 18 '22 06:10

Chia Wei