ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   warning or message before saving spreadsheet (https://www.excelbanter.com/excel-worksheet-functions/28797-warning-message-before-saving-spreadsheet.html)

MissM

warning or message before saving spreadsheet
 
I would like to have a message or warning to show up before saving a
spreadsheet template I've made if certain cells have been left empty. Is that
possible?

Don Guillett

look in the ThisWorkbook module for before close

--
Don Guillett
SalesAid Software

"MissM" wrote in message
...
I would like to have a message or warning to show up before saving a
spreadsheet template I've made if certain cells have been left empty. Is

that
possible?




Duke Carey

Yes it is.

Right click on a sheet's tab and choose View Code. In Project Explorer (if
it isn't displayed select it from the View menu) double click ThisWorkbook
under your template's name.

Use code something like (change A1 & B1 to reflect the cells that are of
concern to you)
===========================================

Private Sub Workbook_BeforeClose(Cancel As Boolean)
If Range("A1") = "" Or Range("B1") = "" Then
MsgBox "Must complete cells A1 & B1 before closing" _
, vbCritical, "Error"
Cancel = True
End If

End Sub

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, _
Cancel As Boolean)
If Range("A1") = "" Or Range("B1") = "" Then
MsgBox "Must complete cells A1 & B1 before closing" _
, vbCritical, "Error"
Cancel = True
End If

End Sub

===========================================
"MissM" wrote:

I would like to have a message or warning to show up before saving a
spreadsheet template I've made if certain cells have been left empty. Is that
possible?


Daniel CHEN

Try something like:

Private Sub Workbook_BeforeClose(Cancel As Boolean)
If Range(A1) = "" Then
MsgBox "Err"
End If
End Sub

===== * ===== * ===== * =====
Daniel CHEN

Spreadsheet/VBA Specialist

www.Geocities.com/UDQServices
Your "Impossible" Task Could Be Someone Else's "Piece of Cake"
===== * ===== * ===== * =====


"Don Guillett" wrote in message
...
look in the ThisWorkbook module for before close

--
Don Guillett
SalesAid Software

"MissM" wrote in message
...
I would like to have a message or warning to show up before saving a
spreadsheet template I've made if certain cells have been left empty. Is

that
possible?







All times are GMT +1. The time now is 07:08 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com