+ Reply to Thread
Results 1 to 5 of 5

ok cancel dialog box

  1. #1
    shishi
    Guest

    ok cancel dialog box

    Hi all,

    I am trying to do a simple dialog box. I can't figure out how I can
    do this. The user has to select appropriate cell ( by clicking into a
    cell) in a work sheet to have the output of a macro go into that cell.
    Now I wish to provide a dialog box that has ok and cancel. If the user
    is ready for the output, he needs to click and select the appropriate
    cell in the sheet and then click ok. If user wants to cancel, he can
    click on cancel and the function will not run. I am trying to implement
    this..Any ideas..thanks in advance...

    shishi


  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello Shishi,

    You may have a problem doing this. Both the MsgBox and InputBox use modal dialogs. Once displayed you can not select anything on the Worksheet. When is the MsgBox called and by what?

    Sincerely,
    Leith Ross
    Last edited by Leith Ross; 02-02-2006 at 02:44 PM.

  3. #3
    Charlie
    Guest

    RE: ok cancel dialog box

    Private Sub Worksheet_SelectionChange(ByVal Target As Range)

    If Target.Address(False, False) = "A1" Then
    If MsgBox("Ready?", vbOKCancel) = vbOK Then MyMacroRunsHere
    End If

    End Sub


    "shishi" wrote:

    > Hi all,
    >
    > I am trying to do a simple dialog box. I can't figure out how I can
    > do this. The user has to select appropriate cell ( by clicking into a
    > cell) in a work sheet to have the output of a macro go into that cell.
    > Now I wish to provide a dialog box that has ok and cancel. If the user
    > is ready for the output, he needs to click and select the appropriate
    > cell in the sheet and then click ok. If user wants to cancel, he can
    > click on cancel and the function will not run. I am trying to implement
    > this..Any ideas..thanks in advance...
    >
    > shishi
    >
    >


  4. #4
    Tim Williams
    Guest

    Re: ok cancel dialog box

    Sub Test()
    Dim v As Object

    On Error Resume Next
    Set v = Application.InputBox(prompt:="Select a cell for output, or
    cancel", Type:=8)
    On Error GoTo 0

    If Not v Is Nothing Then
    MsgBox "User selected range " & v.Address
    Else
    MsgBox "User cancelled"
    End If

    End Sub

    --
    Tim Williams
    Palo Alto, CA


    "shishi" <[email protected]> wrote in message
    news:[email protected]...
    > Hi all,
    >
    > I am trying to do a simple dialog box. I can't figure out how I can
    > do this. The user has to select appropriate cell ( by clicking into a
    > cell) in a work sheet to have the output of a macro go into that cell.
    > Now I wish to provide a dialog box that has ok and cancel. If the user
    > is ready for the output, he needs to click and select the appropriate
    > cell in the sheet and then click ok. If user wants to cancel, he can
    > click on cancel and the function will not run. I am trying to implement
    > this..Any ideas..thanks in advance...
    >
    > shishi
    >




  5. #5
    shishi
    Guest

    Re: ok cancel dialog box

    Here is the code snippet...

    Sub DesignateStartingCell()
    MsgBox "Select the starting cell for the first column"
    Call GenerateNames("START_SPEC", "SPECS")

    End Sub

    The GenerateNames("START_SPEC", "SPECS"), is going to the generate a
    NAMED RANGE at the selected cell. The name is START_SPEC and the sheet
    name is SPECS.

    May be I should use a msg like "Have you selected appropriate starting
    Cell?" If the user clicks on YES, the code runs and if the user clicks
    on NO the exit without calling GenerateNames("START_SPEC", "SPECS")...


+ 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