必填字段红色。 现在如何保存?

它做什么:需要来自用户的字段。 如果特定字段丢失,阻止用户保存。 将这些字段变成红色,直到正确保存。

我需要什么:那么,我该怎么救这个…

我想要什么:由于工作表是空白的。 我无法保存。 和必填字段是红色的。 即使我可以拯救,我也会像细胞一样没有填充,直到我推出。

在这里查看原文

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 

如果您正处在开发中,想要“打破规则”,并节省您当前的努力,那么在标准模块中:

 Sub MyPrivateSave() Application.EnableEvents = False ThisWorkbook.Save Application.EnableEvents = True End Sub 

当然,当你完成开发时,你会删除这个小的“保存工具”,然后将工作簿发送给用户。

或添加作为第一行if environ("Username")=your username then exit sub