Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have a sheet that has a command button. One of the tasks I want the macro
do to is delete the sheet that the command button is on. What is the proper way to do that? What do you think of this: On Sheet3 code: Private Sub cmdMigrateWB_Click() MigrateWorkbook end sub In Module1: Sub MigrateWorkbook() On Error GoTo ErrThisSub ' Do a bunch of stuff prevValue = Application.DisplayAlerts Application.DisplayAlerts = False On Error Resume Next 'delete the sheet the cmd button was on Sheets(3).Delete On Error GoTo ErrThisSub Application.DisplayAlerts = prevValue ' do some more stuff Exit Sub ErrThisSub: MsgBox "Error in routine." End Sub It seems to work, but it seems wrong to delete the code that the Module1 macro is trying to return to. The main effect I've seen is that I can't enter debug after the delete has occured. Suggestions? Thanks, John |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Use macro to delete worksheet without specific name Eg:Sheet 1 | Excel Programming | |||
need to modify a macro to prevent it from executing if in wrong area of the sheet | Excel Discussion (Misc queries) | |||
Macro for sheet delete, very easy | Excel Discussion (Misc queries) | |||
recording macro to delete sheet | Excel Programming | |||
macro to delete a sheet | Excel Programming |