Prev: referring cell in macro function
Next: Getting Data Validation to execute when using Paste Special... Val
From: Bob Ptacek on 29 Apr 2010 15:43 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
From: FSt1 on 29 Apr 2010 15:58
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 |