ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Before Save Requirement (https://www.excelbanter.com/excel-programming/287630-before-save-requirement.html)

Phil Hageman[_3_]

Before Save Requirement
 
A user opens a workbook and is requiared to make entries
in certain cells, say A1, B2, C3 and D4. I need code that
prevents them from saving the workbook with these four
cells blank. If one or more are blank, a message informs
them of the oversight. Once corrected, they may save the
workbook. What would the code be?

Thanks, Phil

Township of East Hanover

Before Save Requirement
 
Private Sub Workbook_BeforeClose(Cancel As Boolean)
If Sheet1.Cell(1,1).Value = " " then
MsgBox("Please Enter a value in Cell
A1",vbExclamation+vbOK,"Problem!")
Cancel = True
Else
Cancel = False
end If
If Sheet1.Cell(2,1).Value = " " then
........
End If
.........

End Sub


"Phil Hageman" wrote in message
...
A user opens a workbook and is requiared to make entries
in certain cells, say A1, B2, C3 and D4. I need code that
prevents them from saving the workbook with these four
cells blank. If one or more are blank, a message informs
them of the oversight. Once corrected, they may save the
workbook. What would the code be?

Thanks, Phil




Phil Hageman[_3_]

Before Save Requirement
 
I have entered the code and get a compile syntax error on
this line:

MsgBox("A value greater than zero is required _
for Customer weighting",vbExclamation+vbOK, _
"Data Entry Problem!") <----ENTIRE LINE HIGHLIHTED

The following code is how I have set up the closing
sequence. Should all this code be compressed into one
Sub, or be separate? I'm trying to give the user two
choices: fix the problem, or close without saving.

Option Explicit
----------------------------------------------------
Private Sub Workbook_BeforeClose(Cancel As Boolean)
If Sheet2("Scorecard").Cell(7, 26).Value = " " Then
MsgBox("A value greater than zero is required _
for Customer weighting",vbExclamation+vbOK,"Data
Entry Problem!")
Cancel = True **I plan to add three
Else **additional cells to this.
Cancel = False **How would this be modified?
End If **Or would I repeat the code?
End Sub
---------------------------------------------------------
Sub Auto_Close()
Application.DisplayFullScreen = False
ActiveWindow.DisplayWorkbookTabs = True
ActiveWindow.DisplayHeadings = True
ActiveWindow.DisplayHorizontalScrollBar = True

End Sub



-----Original Message-----
Private Sub Workbook_BeforeClose(Cancel As Boolean)
If Sheet1.Cell(1,1).Value = " " then
MsgBox("Please Enter a value in Cell
A1",vbExclamation+vbOK,"Problem!")
Cancel = True
Else
Cancel = False
end If
If Sheet1.Cell(2,1).Value = " " then
........
End If
.........

End Sub


"Phil Hageman"

wrote in message
...
A user opens a workbook and is requiared to make entries
in certain cells, say A1, B2, C3 and D4. I need code

that
prevents them from saving the workbook with these four
cells blank. If one or more are blank, a message

informs
them of the oversight. Once corrected, they may save

the
workbook. What would the code be?

Thanks, Phil



.



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

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