此特定Excel将位于共享文件夹中,供团队成员填写。
我想在保存之前弹出错误信息。要求是:
以下是我试过的代码。它只给我第一列中的空单元格。如何将其扩展到多个列?
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Dim sourceCol As Integer, rowCount As Integer, currentRow As Integer
Dim currentRowValue As String
sourceCol = 1
rowCount = Cells(Rows.Count, sourceCol).End(xlUp).Row
For currentRow = 1 To rowCount
currentRowValue = Cells(currentRow, sourceCol).Value
If IsEmpty(currentRowValue) Or currentRowValue = "" Then
Cells(currentRow, sourceCol).Select
Exit For
End If
End Sub
我对VBA更新鲜。