My Excel file has two sheets. The first sheet (we will call this sheet1) has one command button, and the second sheet (we will call this sheet2) has two command buttons. If the command button on sheet1 is clicked, it will copy the entire sheet2 to a new sheet (sheet3). Now, since the sheet has been copied to a new sheet, the command buttons in sheet3 lose their code. For example, here is the new code for one of the command buttons in sheet3:
Private Sub CommandButton2_Click()
End Sub
Now what I would like to do is insert some code into this new command button in sheet3 via the command button code from sheet1 that I originally used to copy sheet2 to sheet3. The code I would like to insert is as follows:
Application.DisplayAlerts = False
Sheets("sheet1").Visible = True
Sheets("sheet1").Select
Sheets("sheet3").delete
Application.DisplayAlerts = True
My problem is I do not know how to do this in VBA. Can someone help me out? Thanks!
Bookmarks