Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default How to build dialogue boxes into macros

How do I get XL/VB to return a dialogue box with an specific error-message
(defined by me) when the macro stops for a specific reason.
Example:

If the macro halts on

Sheets("Sheet1").Name = Sheets("Sheet1").Range("c4")

I want a dialouge box to appear with the text: " This name is already in
the database"

I am not an experienced programmer, so I would appreciate an explanation
"for dummies" :-)

Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 400
Default How to build dialogue boxes into macros

You need an error trap. Your should be able to adapt this:

Sub xx()
Erin = "xx"
On Error GoTo errTrap
a = 10
b = a / 0
Exit Sub
errTrap:
MsgBox "Error in " & Erin & " " & Err.Number & " " & Err.Description,
vbOKOnly + vbCritical
End Sub


"Zyvind" wrote:

How do I get XL/VB to return a dialogue box with an specific error-message
(defined by me) when the macro stops for a specific reason.
Example:

If the macro halts on

Sheets("Sheet1").Name = Sheets("Sheet1").Range("c4")

I want a dialouge box to appear with the text: " This name is already in
the database"

I am not an experienced programmer, so I would appreciate an explanation
"for dummies" :-)

Thanks

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default How to build dialogue boxes into macros

If you want that, you have to test the condition, and manage it

sName = Sheets("Sheet1").Range("c4")
If SheetsExists(sName) Then
Msgbox "This sheet name is already used"
...
End If

....
....

'-----------------------------------------------------------------
Function SheetExists(Sh As String, _
Optional wb As Workbook) As Boolean
'-----------------------------------------------------------------
Dim oWs As Worksheet
If wb Is Nothing Then Set wb = ActiveWorkbook
On Error Resume Next
SheetExists = CBool(Not wb.Worksheets(Sh) Is Nothing)
On Error GoTo 0
End Function


--

HTH

RP
(remove nothere from the email address if mailing direct)


"Zyvind" wrote in message
...
How do I get XL/VB to return a dialogue box with an specific error-message
(defined by me) when the macro stops for a specific reason.
Example:

If the macro halts on

Sheets("Sheet1").Name = Sheets("Sheet1").Range("c4")

I want a dialouge box to appear with the text: " This name is already in
the database"

I am not an experienced programmer, so I would appreciate an explanation
"for dummies" :-)

Thanks



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Two responding dialogue boxes for data validation FARAZ QURESHI Excel Discussion (Misc queries) 2 January 19th 07 04:47 AM
Enable/Disable Macros dialogue box when user opens Excel David Excel Discussion (Misc queries) 2 August 23rd 06 02:21 PM
build complex formulas using the dialogue box travis Excel Discussion (Misc queries) 2 August 23rd 06 01:28 PM
Showing built in dialogue boxes No Name Excel Programming 3 September 22nd 04 01:05 PM
How to build build a macro that automatically imports PedroPeso Excel Programming 1 December 26th 03 08:14 PM


All times are GMT +1. The time now is 03:38 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"