我使用宏录制器来发现ActiveSheet.CircleInvalid,它会圈出任何不符合单元格数据验证条件的数据。我将宏链接到表单控件;到目前为止,我有:
Sub datavalidationcheck()
ActiveSheet.CircleInvalid
'//Add if there are invalid cells being circled then prompt user with dialog box
'//else
Application.Dialogs(xlDialogSendMail).Show
End Sub
我希望了解如何创建一个请求用户修复无效数据的对话框。注释掉的东西是我想要完成的伪代码。
由于
答案 0 :(得分:4)
这是一个想法,它基于以下事实:无效数据周围的圆圈是工作表上的实际形状:
Sub Invalid()
Dim ws As Excel.Worksheet
Dim cell As Excel.Range
Dim ShapesBefore As Long
Dim ShapesAfter As Long
Set ws = ActiveSheet
Set cell = ActiveCell
With ws
.ClearCircles
ShapesBefore = ws.Shapes.Count
.CircleInvalid
ShapesAfter = ws.Shapes.Count
If ShapesAfter > ShapesBefore Then
MsgBox "Invalid Circles displayed"
End If
End With
End Sub