Conell8383
Board Regular
- Joined
- Jul 26, 2016
- Messages
- 66
I hope you can help I have the below piece of code and I am getting runtime error 13 on this line
What I am trying to achieve is to not let a user save the Excel workbook without populating the cells in the range ("A11:C100") The code works fine if it is just ("A11") but if I increase the range I get the error.
The rest of my code is below any help would be greatly appreciated.
Code:
If Sheets("Input").Range("A11:C100").Value = "" Then
What I am trying to achieve is to not let a user save the Excel workbook without populating the cells in the range ("A11:C100") The code works fine if it is just ("A11") but if I increase the range I get the error.
The rest of my code is below any help would be greatly appreciated.
Code:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
'Step 1: Check to see if Cell A11 to C100 is blank
If Sheets("Input").Range("A11:C100").Value = "" Then
'Step 2: Blank: cancel the Close and tell the user
Cancel = True
MsgBox "Cells A11 to C100 can not be blank"
'Step 3: Not Blank; Save and Close
Else
ActiveWorkbook.Close SaveChanges:=True
End If
End Sub