msgbox display... help

UKPhil

New Member
Joined
Jul 25, 2002
Messages
49
I have a msgbox which I want to use to display a generated document number after an event.I have the code:
answer = Notify("Document number:")
How do I display the number using the cell reference in this box?

I know this isn't rocket science but my books offer no help on this!
once again thanks in advance
UKPhil
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.

Jim North

MrExcel MVP
Joined
Jun 20, 2002
Messages
791
On 2002-09-12 05:54, UKPhil wrote:
I have a msgbox which I want to use to display a generated document number after an event.I have the code:
answer = Notify("Document number:")
How do I display the number using the cell reference in this box?

I know this isn't rocket science but my books offer no help on this!
once again thanks in advance
UKPhil

assuming DocNbr is the variable with your docment number in it...

s = "Document Number: " & DocNbr
answer = MsgBox s

... check out the help text... there's quite a bit on MsgBox
 

Joe Was

MrExcel MVP
Joined
Feb 19, 2002
Messages
7,539
Sub CapBarCell()
'Add a message to the Excel Caption Bar at the top of the screen.
ActiveWindow.Caption = ""
Application.Caption = "Document number: " & Worksheets("Sheet1").Range("A1").Value
End Sub

Hope this helps. JSW
 

UKPhil

New Member
Joined
Jul 25, 2002
Messages
49
Well... Joe's solution works, but its not what I'm looking for. Jim's solution just does not seem to work - comes up with a compile error in the code.
 

Jim North

MrExcel MVP
Joined
Jun 20, 2002
Messages
791

ADVERTISEMENT

Are you using OPTION EXPLICIT? Make sure you variables are defined. What the compiler error, and on what line.

Posting your code would help. If you put <pre> before and </pre> after your code the indenting is preserved.
 

UKPhil

New Member
Joined
Jul 25, 2002
Messages
49
Jim, have no Idea about what you mean when you say Option explicit.

Error message is compile error: expected end of statement

code is as follows:
<pre>
Function Notify(msg)
btns = vbOKOnly + vbQuestion + vbDefaultButton1
msgboxtitle = "Record added successfully"
Notify = MsgBox(CStr(msg), btns, msgboxtitle)
End Function

Sub Showdialogbox()
s = "Document Number: " & docno
answer = MsgBox s

End Sub
</pre>
I have docno as a named range within the sheet but not defined as a variable within the module. How do I do this?
 

Jim North

MrExcel MVP
Joined
Jun 20, 2002
Messages
791

ADVERTISEMENT

This should stop the pain:

<pre>
Sub Notify()

btns = vbOKOnly + vbQuestion + vbDefaultButton1
msgboxtitle = "Record added successfully"
msg = "Document Number: " & Range("docno").Value
answer = MsgBox(msg, btns, msgboxtitle)

End Sub
</pre>
 

UKPhil

New Member
Joined
Jul 25, 2002
Messages
49
Hate to say this Jim....

copied that code in exactly as you put it...

gives me
compile error: syntax error

AAAArrrrrrggggghhhhh!
My brain hurts.
 

UKPhil

New Member
Joined
Jul 25, 2002
Messages
49
Sorted.... Thanx Jim
A kind of mix of the two codes seems to work... finally got there with:
<pre>Function Notify(msg)
btns = vbOKOnly + vbQuestion + vbDefaultButton1
MsgBoxtitle = "Record added successfully"
Notify = MsgBox(CStr(msg), btns, MsgBoxtitle)
End Function

Sub Showdialogbox()

answer = Notify("Document No: " & Range("docno").Value)

End Sub
</Pre>
I should know better than to try VBA! one ) out of place and 2 hours scratching my Head!
Cheers Jim
 

Forum statistics

Threads
1,143,613
Messages
5,719,708
Members
422,242
Latest member
hishamkhatri

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top