Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
Please assist me on how to write an excel VBA code to prompt a message " No sheet is to be delete, OK" instead of prompting a VBA error message when I accidentally run a DeleteSheet macro, which had already deleted all sheets in a workbook. With this additional codes so that the DeleteSheet macro can be run more smoothly. Thanks Regards Lenard |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi
do you mean msgbox? -- Regards Frank Kabel Frankfurt, Germany "ltong" schrieb im Newsbeitrag om... Hi, Please assist me on how to write an excel VBA code to prompt a message " No sheet is to be delete, OK" instead of prompting a VBA error message when I accidentally run a DeleteSheet macro, which had already deleted all sheets in a workbook. With this additional codes so that the DeleteSheet macro can be run more smoothly. Thanks Regards Lenard |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Lenard,
I believe a workbook must have at least 1 worksheet. So your sub could have something like: If ThisWorkbook.Worksheets.Count 1 Then 'run your deletesheets sub Else MsgBox prompt:="This worrkbook must have at least 1 sheet." End If Geof. -----Original Message----- Hi, Please assist me on how to write an excel VBA code to prompt a message " No sheet is to be delete, OK" instead of prompting a VBA error message when I accidentally run a DeleteSheet macro, which had already deleted all sheets in a workbook. With this additional codes so that the DeleteSheet macro can be run more smoothly. Thanks Regards Lenard . |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi all,
Frank, yes it is a msgbox and I got the VBA code from Geof Thank you, Geof and it works. By the way, I need another VBA code to prompt a message again " Sorry, the selected sheet for deletion is not found, OK " ? and it ends the VBA code instead of prompting VBA error . Regards Lenard "Geof Wyght" wrote in message ... Lenard, I believe a workbook must have at least 1 worksheet. So your sub could have something like: If ThisWorkbook.Worksheets.Count 1 Then 'run your deletesheets sub Else MsgBox prompt:="This worrkbook must have at least 1 sheet." End If Geof. -----Original Message----- Hi, Please assist me on how to write an excel VBA code to prompt a message " No sheet is to be delete, OK" instead of prompting a VBA error message when I accidentally run a DeleteSheet macro, which had already deleted all sheets in a workbook. With this additional codes so that the DeleteSheet macro can be run more smoothly. Thanks Regards Lenard . |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Display your own Run Time Errors:
Sub MyMacro() On Error Goto MyError 'Your code here Exit sub MyError: MsgBox "An error has occured" End Sub For more info go to http://www.ozgrid.com/VBA/ExcelVBAErrors.htm "ltong" wrote in message m... Hi all, Frank, yes it is a msgbox and I got the VBA code from Geof Thank you, Geof and it works. By the way, I need another VBA code to prompt a message again " Sorry, the selected sheet for deletion is not found, OK " ? and it ends the VBA code instead of prompting VBA error . Regards Lenard "Geof Wyght" wrote in message ... Lenard, I believe a workbook must have at least 1 worksheet. So your sub could have something like: If ThisWorkbook.Worksheets.Count 1 Then 'run your deletesheets sub Else MsgBox prompt:="This worrkbook must have at least 1 sheet." End If Geof. -----Original Message----- Hi, Please assist me on how to write an excel VBA code to prompt a message " No sheet is to be delete, OK" instead of prompting a VBA error message when I accidentally run a DeleteSheet macro, which had already deleted all sheets in a workbook. With this additional codes so that the DeleteSheet macro can be run more smoothly. Thanks Regards Lenard . |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Prompt to Save Message | Excel Discussion (Misc queries) | |||
help with message prompt | New Users to Excel | |||
Disable Message Prompt in VBA | Excel Programming | |||
Data Validation Prompt Message | Excel Programming | |||
Deleting a Prompt Message | Excel Programming |