使用Excel文档,它需要填充几个单元格才能保存。我能够通过以下代码解决这个问题。
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
If Cells(6, 5).Value = "" Then
MsgBox "Cell E6 requires user input", vbInformation, "Kutools for Excel"
Cancel = True
Exit Sub
End If
If Cells(8, 5).Value = "" Then
MsgBox "Cell E8 requires user input", vbInformation, "Kutools for Excel"
Cancel = True
Exit Sub
End If
If Cells(10, 5).Value = "" Then
MsgBox "Cell E10 requires user input", vbInformation, "Kutools for Excel"
Cancel = True
Exit Sub
End If
我遇到的问题是,如果特定单元格已填满,则在保存文档之前需要其他单元格。我已经尝试过isEmpty函数,但它仍然无法正常工作。请帮忙!
答案 0 :(得分:0)
使用If Cells(1,1).Value <> ""
然后需要像你一直在做的其他单元格。像这样:
If Cells(1,1).Value <> "" Then
If Cells(10, 5).Value = "" Then
MsgBox "Cell E10 requires user input", vbInformation, "Kutools for Excel"
Cancel = True
Exit Sub
End If
End If