Prohibit / generate pop up if saving a file with missing data in cells

mickyd67

Board Regular
Joined
Jul 13, 2011
Messages
80
Office Version
  1. 365
Platform
  1. Windows
Hi all - first post, be kind :)

I am looking for a way to either stop someone saving a file and / or giving them a pop up notice to advise them that certain cells in a spreasheet must be completed for the file to be valid.

Is this possible? Any hints / tips?

Cheers,
MD
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
What cells and sheets must be checked?
 
Last edited:
Upvote 0
What cells must and what sheet be checked?

Hello there - not sure I follow your question.

Let's just say in cell A1 you must put a valid date in - if you don't put anything in then it would alert you that the spreadsheet hasn't been compelted correctly.

In cell A2 you must put your name, for example. Again, if you don't then it won't allow you to save.
 
Upvote 0
In ThisWorkbook module. Rename sheet and ranges to appropriate.
Code:
[COLOR="Blue"]Private[/COLOR] [COLOR="Blue"]Sub[/COLOR] Workbook_BeforeSave([COLOR="Blue"]ByVal[/COLOR] SaveAsUI [COLOR="Blue"]As[/COLOR] [COLOR="Blue"]Boolean[/COLOR], Cancel [COLOR="Blue"]As[/COLOR] Boolean)
    [COLOR="Blue"]With[/COLOR] Sheets("Sheet1")
        Cancel = IsEmpty(.Range("A1")) [COLOR="Blue"]Or[/COLOR] IsEmpty(Range("A2"))
    [COLOR="Blue"]End[/COLOR] [COLOR="Blue"]With[/COLOR]
[COLOR="Blue"]End[/COLOR] [COLOR="Blue"]Sub[/COLOR]
 
Upvote 0
In ThisWorkbook module. Rename sheet and ranges to appropriate.
Code:
[COLOR=blue]Private[/COLOR] [COLOR=blue]Sub[/COLOR] Workbook_BeforeSave([COLOR=blue]ByVal[/COLOR] SaveAsUI [COLOR=blue]As[/COLOR] [COLOR=blue]Boolean[/COLOR], Cancel [COLOR=blue]As[/COLOR] Boolean)
    [COLOR=blue]With[/COLOR] Sheets("Sheet1")
        Cancel = IsEmpty(.Range("A1")) [COLOR=blue]Or[/COLOR] IsEmpty(Range("A2"))
    [COLOR=blue]End[/COLOR] [COLOR=blue]With[/COLOR]
[COLOR=blue]End[/COLOR] [COLOR=blue]Sub[/COLOR]

Hi there - thanks for the reply. I tried this but Excel lets me close any open file without any warning or prompt.

Not sure if I am adding the data above correctly - so it might be my fault it's not working.

Any other suggestions?

Cheers.
 
Upvote 0

Forum statistics

Threads
1,224,583
Messages
6,179,673
Members
452,937
Latest member
Bhg1984

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top