ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   How do I prevent saving an excel file if cells are blank? (https://www.excelbanter.com/excel-worksheet-functions/117518-how-do-i-prevent-saving-excel-file-if-cells-blank.html)

Leighann

How do I prevent saving an excel file if cells are blank?
 
How do I prevent saving an excel file if cells are blank?

Ron de Bruin

How do I prevent saving an excel file if cells are blank?
 
Hi Leighann

You can use the before save event

Copy this event in the Thisworkbook module
Change the sheet name and ranges in this line
Set myrange = Worksheets("Sheet1").Range("A1:A6,C10,D12,G1:G3")

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Dim myrange As Range
Set myrange = Worksheets("Sheet1").Range("A1:A6,C10,D12,G1:G3")
If Application.WorksheetFunction.CountA(myrange) < _
myrange.Cells.Count Then
MsgBox "fill in all cells"
Cancel = True
End If
End Sub



--
Regards Ron de Bruin
http://www.rondebruin.nl



"Leighann" wrote in message ...
How do I prevent saving an excel file if cells are blank?





All times are GMT +1. The time now is 10:36 AM.

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