+ Reply to Thread
Results 1 to 5 of 5

Create a prompt as a person saves a file

  1. #1
    ah
    Guest

    Create a prompt as a person saves a file

    I would like to create a prompt that will pop up as a user tries to save a
    file and ask them have they filled in a certain cell, say "A2"

    Can anybody help?
    --
    thanks

    ah

  2. #2
    Oliver Ferns via OfficeKB.com
    Guest

    Re: Create a prompt as a person saves a file

    Hi,
    Go to the ThisWorkbook class module and enter the following code...

    Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
    Boolean)

    If Me.Sheets(1).Range("$A$2").Value = "" Then
    MsgBox "You have not entered a value in cell A2 on the first sheet!"
    ''whatever message you want
    Let Cancel = True
    End If

    End Sub


    Hth,
    Oli

    --
    Message posted via http://www.officekb.com

  3. #3
    John Mansfield
    Guest

    RE: Create a prompt as a person saves a file

    ah,

    This VBA routine will work. To add it to your worksheet, go to Tools ->
    Macro -> Visual Basic Editor. In the left side structure of the Visual Basic
    Editor, look for "ThisWorkbook". Double click on ThisWorkbook and macro
    below to the code module. After you add the macro, hit File -> Close. Then,
    save your file.

    Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
    Dim Msg, Style, Title, Help, Ctxt, Response, MyString
    Msg = "Did you fill in cell A2?"
    Style = vbYesNo
    Title = "Save Data Prompt"
    Response = MsgBox(Msg, Style, Title)
    If Response = vbYes Then
    Exit Sub
    Else
    Cancel = True
    End If
    End Sub

    ----
    Regards,
    John Mansfield
    http://www.pdbook.com

    "ah" wrote:

    > I would like to create a prompt that will pop up as a user tries to save a
    > file and ask them have they filled in a certain cell, say "A2"
    >
    > Can anybody help?
    > --
    > thanks
    >
    > ah


  4. #4
    ah
    Guest

    RE: Create a prompt as a person saves a file

    Thanks very much, this is excellent

    "John Mansfield" wrote:

    > ah,
    >
    > This VBA routine will work. To add it to your worksheet, go to Tools ->
    > Macro -> Visual Basic Editor. In the left side structure of the Visual Basic
    > Editor, look for "ThisWorkbook". Double click on ThisWorkbook and macro
    > below to the code module. After you add the macro, hit File -> Close. Then,
    > save your file.
    >
    > Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
    > Dim Msg, Style, Title, Help, Ctxt, Response, MyString
    > Msg = "Did you fill in cell A2?"
    > Style = vbYesNo
    > Title = "Save Data Prompt"
    > Response = MsgBox(Msg, Style, Title)
    > If Response = vbYes Then
    > Exit Sub
    > Else
    > Cancel = True
    > End If
    > End Sub
    >
    > ----
    > Regards,
    > John Mansfield
    > http://www.pdbook.com
    >
    > "ah" wrote:
    >
    > > I would like to create a prompt that will pop up as a user tries to save a
    > > file and ask them have they filled in a certain cell, say "A2"
    > >
    > > Can anybody help?
    > > --
    > > thanks
    > >
    > > ah


  5. #5
    ah
    Guest

    Re: Create a prompt as a person saves a file

    This works thansk very much

    "Oliver Ferns via OfficeKB.com" wrote:

    > Hi,
    > Go to the ThisWorkbook class module and enter the following code...
    >
    > Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
    > Boolean)
    >
    > If Me.Sheets(1).Range("$A$2").Value = "" Then
    > MsgBox "You have not entered a value in cell A2 on the first sheet!"
    > ''whatever message you want
    > Let Cancel = True
    > End If
    >
    > End Sub
    >
    >
    > Hth,
    > Oli
    >
    > --
    > Message posted via http://www.officekb.com
    >


+ 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