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

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
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
 
Upvote 0
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
 
Upvote 0
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.
 
Upvote 0
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.
 
Upvote 0
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?
 
Upvote 0
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>
 
Upvote 0
Hate to say this Jim....

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

gives me
compile error: syntax error

AAAArrrrrrggggghhhhh!
My brain hurts.
 
Upvote 0
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
 
Upvote 0

Forum statistics

Threads
1,213,536
Messages
6,114,208
Members
448,554
Latest member
Gleisner2

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
Back
Top