dave843
04-11-2020, 09:39 PM
Hi,
I have a spreadsheet with a table in it and I want to make sure all cells have a value before the spreadsheet is saved. The code below seems to work if there is an empty cell within the table, however I get an error when there a no empty cells. Any help will be greatly appreciated!
Thanks
Dave
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
If ActiveSheet.ListObjects("HCIIP_Table").DataBodyRange.SpecialCells(xlCellTypeBlanks).Count > 0 Then
MsgBox "There are empty cells within the table."
Cancel = True
End If
End Sub
I have a spreadsheet with a table in it and I want to make sure all cells have a value before the spreadsheet is saved. The code below seems to work if there is an empty cell within the table, however I get an error when there a no empty cells. Any help will be greatly appreciated!
Thanks
Dave
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
If ActiveSheet.ListObjects("HCIIP_Table").DataBodyRange.SpecialCells(xlCellTypeBlanks).Count > 0 Then
MsgBox "There are empty cells within the table."
Cancel = True
End If
End Sub