EliseFreedman
Programmer
Hi There
I have been tasked with building a balanced scorecard application using Excel. The idea is that individual scorecards can be emailed out to different departments. The department completes the scorecard and emails it back to us. The problem I have got is how do I ensure that ALL the fields have been completed before the file is sent back? I am using the code below to check the data input when the file is saved. This works fine. However, it is fairly simple to Go to the File Menu and select "Send File as attachment" without actually saving the file therefore bypassing the validation routine. I am aware that I could attach the code to a command button which validates the input and then emails the sheet. The trouble I have got is that due to security issues in our Network not all users are able to run macros and thefore have to resort to using "File, Send To". Does anyone have any ideas how I can get round this and validate the data before the "File, Send To" is performed?
I have been tasked with building a balanced scorecard application using Excel. The idea is that individual scorecards can be emailed out to different departments. The department completes the scorecard and emails it back to us. The problem I have got is how do I ensure that ALL the fields have been completed before the file is sent back? I am using the code below to check the data input when the file is saved. This works fine. However, it is fairly simple to Go to the File Menu and select "Send File as attachment" without actually saving the file therefore bypassing the validation routine. I am aware that I could attach the code to a command button which validates the input and then emails the sheet. The trouble I have got is that due to security issues in our Network not all users are able to run macros and thefore have to resort to using "File, Send To". Does anyone have any ideas how I can get round this and validate the data before the "File, Send To" is performed?
Code:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
If WorksheetFunction.CountA(Sheet1.Range("L16:L28")) < 13 Then
MsgBox "Please enter a grading in all cells", vbCritical
Cancel = True
Exit Sub
End If
If WorksheetFunction.CountA(Sheet1.Range("G5")) < 1 Then
MsgBox "Please enter a department name", vbCritical
Cancel = True
Exit Sub
End If
End Sub