类型不匹配错误IF语句

时间:2015-02-26 09:08:30

标签: excel-vba if-statement vba excel

我正在尝试创建一个“销售页面”,用户可以在其中输入每天销售的详细信息。我正在使用一个用户表单,我试图让它进入当天,如果它不正确,那么显示一个消息框,不要运行其余的功能。无论如何,我一直在代码的这一部分得到类型不匹配错误,我不知道为什么

If salday <> "Monday" _ Or "Tuesday" _ Or "Wednesday" _ Or "Thursday" _ Or "Friday" _ Or "Saturday" _ Or "Sunday" Then MsgBox "Incorrect Day. Please make sure you are using capitals!" Else

如果有人能提供帮助那就太棒了:D

1 个答案:

答案 0 :(得分:0)

试试这个:

dim salday  as string
If salday <> "Monday" _
and salday <> "Tuesday" _
and salday <> "Wednesday" _
and salday <> "Thursday" _
and salday <> "Friday" _
and salday <> "Saturday" _
and salday <> "Sunday" Then
MsgBox "Incorrect Day. Please make sure you are using capitals!"
Else