功能:需要用户输入字段。如果特定字段丢失,阻止用户保存。将这些字段变成红色,直到正确保存。必填字段红色。现在如何保存?
我需要什么:嗯,我究竟如何我应该保存这个...
我想什么:由于工作表是空白。我无法保存。并且必填字段为红色。即使我能拯救我也会像细胞一样没有填充,直到我推出它。
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Dim xlSht As Worksheet
Dim cellsNotPopulated As Boolean
cellsNotPopulated = False
Set xlSht = ThisWorkbook.Worksheets("1st Call")
With xlSht
If .Range("F7") = "" Then
.Range("F7").Interior.Color = RGB(255, 0, 0)
cellsNotPopulated = True
Else
.Range("F7").Interior.ColorIndex = xlNone
End If
End With
If cellsNotPopulated = True Then
MsgBox "Please review the highlighted cells and ensure the fields are populated."
Cancel = True
End If
End Sub
可以检查另一值的第一行,所以如果.Range( “F7”)= “” 和.Range( “G7”)<> “” –