+ Reply to Thread
Results 1 to 4 of 4

VBA Referencing a cell

  1. #1
    Forum Contributor
    Join Date
    05-09-2005
    Location
    SC
    Posts
    196

    VBA Referencing a cell

    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

  2. #2
    Jim Thomlinson
    Guest

    RE: VBA Referencing a cell

    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...
    --
    HTH...

    Jim Thomlinson


    "EMoe" wrote:

    >
    > 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
    >
    >
    > --
    > EMoe
    > ------------------------------------------------------------------------
    > EMoe's Profile: http://www.excelforum.com/member.php...o&userid=23183
    > View this thread: http://www.excelforum.com/showthread...hreadid=498074
    >
    >


  3. #3
    JE McGimpsey
    Guest

    Re: VBA Referencing a cell

    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



    In article <[email protected]>,
    EMoe <[email protected]> wrote:

    > 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


  4. #4
    Forum Contributor
    Join Date
    05-09-2005
    Location
    SC
    Posts
    196
    Thanks for the reply. I'm still analyzing the codes. May post another question later.

    EMoe

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1