+ Reply to Thread
Results 1 to 7 of 7

Thread: Macro

  1. #1
    John
    Guest

    Macro

    I think this is doable and easy, but i can not figure it out for the life of
    me.

    I have a macro that clears on the information from the screen. Can you have
    something in the macro, that will prompt the user to ask a question, such as,
    "Are you sure you want to clear all this information" The user can then
    click yes or no. I guess it is similar to a validation.


  2. #2
    David Hepner
    Guest

    RE: Macro

    Try this:

    Sub Clear_Screen()

    Dim response As Integer
    Dim msg As String

    msg = "Are you sure you want to clear all this information"
    response = MsgBox(msg, vbYesNo, "WARNING")
    If response = vbYes Then
    'Enter existing code that clears the screen
    Else
    'Do something else
    End If

    End Sub




    "John" wrote:

    > I think this is doable and easy, but i can not figure it out for the life of
    > me.
    >
    > I have a macro that clears on the information from the screen. Can you have
    > something in the macro, that will prompt the user to ask a question, such as,
    > "Are you sure you want to clear all this information" The user can then
    > click yes or no. I guess it is similar to a validation.
    >


  3. #3
    Chip Pearson
    Guest

    Re: Macro

    Just a very small point,

    Dim response As Integer

    should be

    Dim response As Long
    or better, in Excel 2000 or later,
    Dim response As VbMsgBoxResult


    --
    Cordially,
    Chip Pearson
    Microsoft MVP - Excel
    Pearson Software Consulting, LLC
    www.cpearson.com


    "David Hepner" <DavidHepner@discussions.microsoft.com> wrote in
    message
    news:A6282921-6AAF-4C8A-B26C-4614955ADE63@microsoft.com...
    > Try this:
    >
    > Sub Clear_Screen()
    >
    > Dim response As Integer
    > Dim msg As String
    >
    > msg = "Are you sure you want to clear all this information"
    > response = MsgBox(msg, vbYesNo, "WARNING")
    > If response = vbYes Then
    > 'Enter existing code that clears the screen
    > Else
    > 'Do something else
    > End If
    >
    > End Sub
    >
    >
    >
    >
    > "John" wrote:
    >
    >> I think this is doable and easy, but i can not figure it out
    >> for the life of
    >> me.
    >>
    >> I have a macro that clears on the information from the screen.
    >> Can you have
    >> something in the macro, that will prompt the user to ask a
    >> question, such as,
    >> "Are you sure you want to clear all this information" The
    >> user can then
    >> click yes or no. I guess it is similar to a validation.
    >>




  4. #4
    FSt1
    Guest

    RE: Macro

    hi,
    yes

    msgbox("are you sure???",vbyesnow, warning)

    look up msgbox in vb help (not excel help)

    regards
    FSt1

    "John" wrote:

    > I think this is doable and easy, but i can not figure it out for the life of
    > me.
    >
    > I have a macro that clears on the information from the screen. Can you have
    > something in the macro, that will prompt the user to ask a question, such as,
    > "Are you sure you want to clear all this information" The user can then
    > click yes or no. I guess it is similar to a validation.
    >


  5. #5
    John
    Guest

    RE: Macro

    Thanks David, however
    IT clears the page regardless of it i hit Yes or No.

    Do i have to put the Else, way down at the end of the macro?

    "David Hepner" wrote:

    > Try this:
    >
    > Sub Clear_Screen()
    >
    > Dim response As Integer
    > Dim msg As String
    >
    > msg = "Are you sure you want to clear all this information"
    > response = MsgBox(msg, vbYesNo, "WARNING")
    > If response = vbYes Then
    > 'Enter existing code that clears the screen
    > Else
    > 'Do something else
    > End If
    >
    > End Sub
    >
    >
    >
    >
    > "John" wrote:
    >
    > > I think this is doable and easy, but i can not figure it out for the life of
    > > me.
    > >
    > > I have a macro that clears on the information from the screen. Can you have
    > > something in the macro, that will prompt the user to ask a question, such as,
    > > "Are you sure you want to clear all this information" The user can then
    > > click yes or no. I guess it is similar to a validation.
    > >


  6. #6
    David Hepner
    Guest

    RE: Macro

    John,

    You must must the existing macro that clears the sheets and paste it uder
    the section 'Enter existing code that clears the screen. If you have done
    this and it still doesn't work. Copy your macro code and post it so I can
    look at it.

    "John" wrote:

    > Thanks David, however
    > IT clears the page regardless of it i hit Yes or No.
    >
    > Do i have to put the Else, way down at the end of the macro?
    >
    > "David Hepner" wrote:
    >
    > > Try this:
    > >
    > > Sub Clear_Screen()
    > >
    > > Dim response As Integer
    > > Dim msg As String
    > >
    > > msg = "Are you sure you want to clear all this information"
    > > response = MsgBox(msg, vbYesNo, "WARNING")
    > > If response = vbYes Then
    > > 'Enter existing code that clears the screen
    > > Else
    > > 'Do something else
    > > End If
    > >
    > > End Sub
    > >
    > >
    > >
    > >
    > > "John" wrote:
    > >
    > > > I think this is doable and easy, but i can not figure it out for the life of
    > > > me.
    > > >
    > > > I have a macro that clears on the information from the screen. Can you have
    > > > something in the macro, that will prompt the user to ask a question, such as,
    > > > "Are you sure you want to clear all this information" The user can then
    > > > click yes or no. I guess it is similar to a validation.
    > > >


  7. #7
    David Hepner
    Guest

    RE: Macro

    I cannot type or read today:

    You must cut the existing macro that clears the sheets and paste it under
    the section 'Enter existing code that clears the screen. If you have done
    this and it still doesn't work. Copy your macro code and post it so I can
    look at it.


    "David Hepner" wrote:

    > John,
    >
    > You must must the existing macro that clears the sheets and paste it uder
    > the section 'Enter existing code that clears the screen. If you have done
    > this and it still doesn't work. Copy your macro code and post it so I can
    > look at it.
    >
    > "John" wrote:
    >
    > > Thanks David, however
    > > IT clears the page regardless of it i hit Yes or No.
    > >
    > > Do i have to put the Else, way down at the end of the macro?
    > >
    > > "David Hepner" wrote:
    > >
    > > > Try this:
    > > >
    > > > Sub Clear_Screen()
    > > >
    > > > Dim response As Integer
    > > > Dim msg As String
    > > >
    > > > msg = "Are you sure you want to clear all this information"
    > > > response = MsgBox(msg, vbYesNo, "WARNING")
    > > > If response = vbYes Then
    > > > 'Enter existing code that clears the screen
    > > > Else
    > > > 'Do something else
    > > > End If
    > > >
    > > > End Sub
    > > >
    > > >
    > > >
    > > >
    > > > "John" wrote:
    > > >
    > > > > I think this is doable and easy, but i can not figure it out for the life of
    > > > > me.
    > > > >
    > > > > I have a macro that clears on the information from the screen. Can you have
    > > > > something in the macro, that will prompt the user to ask a question, such as,
    > > > > "Are you sure you want to clear all this information" The user can then
    > > > > click yes or no. I guess it is similar to a validation.
    > > > >


+ 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.2.0