VBA Referencing a cell

E

EMoe

Hello Programmers,

This partial code opens a message box with a question before executing
a code.
Dim t As String
t = MsgBox("Are you sure you want to open the Chemistry sheet?",
vbYesNo)
If t = vbYes Then

How do I write code that pops up a message box like the one above, but
ask if I want to open the file name that is in "Cell A1". The code will
have to grab the file name from "Cell A1", and place it in the message
box.

Thanks,
EMoe
 
G

Guest

if msgbox("Would you like to open file: " & Range("A1").value) = vbYes then
'Open the file...

By the way a message box returns a long, not a string... Not that it matters
with the above code...
 
J

JE McGimpsey

One way:

Dim nResult As Long
nResult = MsgBox( _
Prompt:="Are you sure you want to open file " & _
Range("A1").Text & "?", _
Buttons:=vbYesNo)
If nResult = vbYes Then
'Open the file
Else
'do something else
End If
 
E

EMoe

Thanks for the reply. I'm still analyzing the codes. May post another
question later.

EMoe
 

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