Dialogue Box

G

Guest

Hi

When you merge cells MS Excel warns you and asks for your permissoin to
continue. I like to have a similar facility when running a macro. I would
like the box to ask me for a yes/no or a value?

Could someone help me with VBA codes for doing that please?

Thanks
Varne M
 
N

Norman Jones

Hi M,

Try something like:

'=============>>
Public Sub Tester()
Dim res As VbMsgBoxResult

res = MsgBox(Prompt:="Do you wish to continue", _
Buttons:=vbYesNo, _
Title:="Continue?")

If res = vbNo Then
Exit Sub
End If

'your code

End Sub
'<<=============
 
G

Guest

Hi Norman

Thanks.

I am a little slow to VB so please explain somthing.

My codes are

Sub Deleter

Range("a1").select
Selection.ClearContents

End Sub

Now Norman How I annex my codes with yours? If I start at where you mention
my computer does not pick up the Macro?

Please reply.

Regards

M Varnendra


:
 
N

Norman Jones

Hi M,

Try:

'=============
Public Sub Tester()
Dim res As VbMsgBoxResult

res = MsgBox(Prompt:="Do you wish to continue", _
Buttons:=vbYesNo, _
Title:="Continue")

If res = vbNo Then
Exit Sub
End If
ActiveSheet.Range("A1").ClearContents

End Sub
'<<=============
 
N

Norman Jones

Hi N,
Regardless of yes or no "a1" is deleted. Please check. Thanks.

That is not my experience.

If the user selects the 'No' option, the Exit Sub instruction
prevents the processing of subsequent instructions.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

VBA Codes Protection 2
Menu Restoration 3
Open print dialogue box when click on print icon in tool bar 5
Dialogue box ghosting 2
list box dialogue msgbox 4
VB 6 4
Dialogue box too wide 2
Copy from Excel to Word 2

Top