Incorpoarting cell contents into a message box

C

Colin Hayes

Hi All

I'm trying to incorporate the contents of cell A1 into a message box but
am struggling for syntax. The content of A1 is text resultant of a
formula.

The box has some leading and trailing text ;

MsgBox "Please go to " (contents of A1) " for further information."


Grateful for any advice
 
J

James Ravenswood

Hi All

I'm trying to incorporate the contents of cell A1 into a message box but
am struggling for syntax.  The content of A1 is text resultant of a
formula.

The box has some leading and trailing text ;

MsgBox "Please go to "  (contents of A1)  " for further information."

Grateful for any advice

Sub marine()
MsgBox "Please go to " & Range("A1").Value & " for further
information."
End Sub
 
C

Colin Hayes

Sub marine()
MsgBox "Please go to " & Range("A1").Value & " for further
information."
End Sub

Hi

OK thanks for that.

As the content is a date , it is returning 01/01/2011 in the message
box, when the cell itself is formatted to read January 2011.

Is it possible to modify the code to return a mmmm yyyy format in the
message box?

Thanks again.
 
R

Rick Rothstein

As the content is a date , it is returning 01/01/2011
in the message box, when the cell itself is formatted
to read January 2011.

Is it possible to modify the code to return a
mmmm yyyy format in the message box?

You do realize if you don't tell us all of your conditions up front, there
is minimum chance that we would be able to guess them, right?

Give this code a line a try...

MsgBox "Please go to " & Format(Range("A1").Value, _
Range("A1").NumberFormat) & " for further"

Rick Rothstein (MVP - Excel)
 
C

Colin Hayes

Rick Rothstein said:
You do realize if you don't tell us all of your conditions up front, there
is minimum chance that we would be able to guess them, right?

Give this code a line a try...

MsgBox "Please go to " & Format(Range("A1").Value, _
Range("A1").NumberFormat) & " for further"

Rick Rothstein (MVP - Excel)


Hi

OK thanks for your help. It works fine now.

I'm grateful for your time and expertise.
 
D

Dave Peterson

This may work, too:

MsgBox "Please go to " & Range("A1").text & " for further"
 
C

Colin Hayes

Dave Peterson said:
This may work, too:

MsgBox "Please go to " & Range("A1").text & " for further"

Hi Dave

OK thanks for that - it works perfectly first time also.

Best Wishes
 

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

Top