Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
ah
 
Posts: n/a
Default 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   Report Post  
Oliver Ferns via OfficeKB.com
 
Posts: n/a
Default

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   Report Post  
John Mansfield
 
Posts: n/a
Default

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   Report Post  
ah
 
Posts: n/a
Default

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   Report Post  
ah
 
Posts: n/a
Default

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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Weekly Transaction Processing Ralph Howarth Excel Worksheet Functions 4 January 19th 05 05:37 AM
Read Text File into Excel Using VBA Willie T Excel Discussion (Misc queries) 13 January 8th 05 12:37 AM
How to I create a pdf file from Word or Excel files stolitx Excel Discussion (Misc queries) 4 December 28th 04 07:17 PM
how do I create comma and double quote delimited file mikeb Excel Discussion (Misc queries) 1 November 29th 04 10:01 PM
How do I create a .csv file? Anna @ Drohan Co. Excel Worksheet Functions 1 November 16th 04 06:13 PM


All times are GMT +1. The time now is 05:13 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"