VBA UserForm单选按钮错误处理

时间:2016-12-08 23:33:07

标签: vba

Private Sub cmd_OK_Click()

Dim z As Range
Dim x As Object


On Error GoTo errMessage1:
Set z = Selection.SpecialCells(xlCellTypeConstants, xlCellTypeConstants)


If OptUpper Then
For Each x In z
x.Value = UCase(x.Value)
Next x
End If

If OptLower Then
For Each x In z
x.Value = LCase(x.Value)
Next x
End If

If OptTitle Then
For Each x In z
x.Value = StrConv(x.Value, vbProperCase)
Next x
End If

Unload CaseForm

Exit Sub

errMessage1:
If Err.Number = 1004 Then
MsgBox "Please make sure range has a value", vbCritical + vbOKOnly, "Empty Cell Error"
End If

Unload CaseForm

End Sub

如果未选择任何收音机/命令按钮,如何显示msgbox?目前,您可以在未选择任何命令按钮时按确定。我希望用户不按OK,除非选择单选按钮或显示一个消息框告诉他们选择一个选项。

0 个答案:

没有答案