Checking if some cells are empty when file is being saved

  • Follow


Is there something that can be checked if the "Save" function is executed. 

I have a file with a number of worksheets and I don't want a user to be able 
to save it without entering some data. Once the "save" is selected I would 
like to check  to see if all required fields are still empty so I can display 
an error
0
Reply Utf 4/29/2010 7:43:02 PM

hi
you could use the before save event to check certain cells for input.
but since you didn't give a lot of details, i can only give a overly simple 
answer.
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Dim r As Range
Set r = Sheets("sheet1").Range("A2")
If r = "" Then
    MsgBox "the require entry at  " & r.Address & "  need data!"
    r.Select
    Cancel = True
End If
End Sub

the above only check 1 cell and cancels save if no data in the cell.
you would need to reset r to the various cells that need input. not sure how 
many you have.

regards
FSt1

"Bob Ptacek" wrote:

> Is there something that can be checked if the "Save" function is executed. 
> 
> I have a file with a number of worksheets and I don't want a user to be able 
> to save it without entering some data. Once the "save" is selected I would 
> like to check  to see if all required fields are still empty so I can display 
> an error
0
Reply Utf 4/29/2010 7:58:03 PM


1 Replies
372 Views

(page loaded in 0.098 seconds)


Reply: