VBA用For循环判断验证单元格必填,并给出提示内容包含左侧的名称。
- For Each MyRange In ActiveWorkbook.Names
- If Left(MyRange.ToString, 2) <> "F_" And Left(MyRange.ToString, 2) <> "T_" And MyRange.ToString <> "SendDate" And MyRange.ToString <> "TemplateName" Then
- If Range(MyRange.ToString).Cells(0, 0).Value Is Nothing Then
- If Range(MyRange.ToString).Cells(0, 0).Offset(0, -1).MergeCells Then
- If Range(MyRange.ToString).Cells(0, 0).Offset(0, -2).Text <> "" Then
- MessageBox.Show(Range(MyRange.ToString).Cells(0, 0).Offset(0, -2).Text + "不能为空!", "提示!", MessageBoxButton.OK)
- Range(MyRange.ToString).Select()
- Return
- Else
- MessageBox.Show(MyRange.ToString + "不能为空!", "提示!", MessageBoxButton.OK)
- Range(MyRange.ToString).Select()
- Return
- End If
- Else
- If Range(MyRange.ToString).Cells(0, 0).Offset(0, -1).Text <> "" Then
- MessageBox.Show(Range(MyRange.ToString).Cells(0, 0).Offset(0, -1).Text + "不能为空!", "提示!", MessageBoxButton.OK)
- Range(MyRange.ToString).Select()
- Return
- Else
- MessageBox.Show(MyRange.ToString + "不能为空!", "提示!", MessageBoxButton.OK)
- Range(MyRange.ToString).Select()
- Return
- End If
- End If
- End If
- End If
- Next
复制代码
|
|
快表帝国客服01