View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Township of East Hanover Township of East Hanover is offline
external usenet poster
 
Posts: 31
Default Message prompt in VBA

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
.