请帮我获取
的VBA代码我正在向 Excel 中的特定单元格添加 10 位数字
如果为真,我想运行一个宏 如果为 false,则为带有文本的消息框
Sub Run_PNR()
If Cells(E, 7).Value = 0 Then
MsgBox ("Enter Correct PNR Number")
Else
Shell "explorer.exe " & Range("d25").Text
End If
End Sub
使用
Val
函数将单元格内容转换为数字并检查其值:
Dim cellVal as Long
cellVal = Val(ActiveSheeet.Cells(E, 7).Value)
If cellVal < 1000000000 Or cellVal > 9999999999 Then
MsgBox ("Enter Correct PNR Number")
Else
(do whatever needs to be done...)
End If
Sub Run_PNR()
If Len(Range("E7").value) <> 10 Then
MsgBox ("Enter Correct PNR Number")
Else
Shell "explorer.exe " & Range("d25").Text
End If
End Sub