Forms VBA条件If Then变量修改

Forms VBA条件If Then变量修改,forms,excel,vba,checkbox,Forms,Excel,Vba,Checkbox,我试图使用一个“\u1”将来自用户输入表单的信息链接在一起,并有条件地从第二个变量中减去一个。以下是我所拥有的: If strckbx = True & strmonth = "oct" Then Range("C1") = strmonth + "_" + (strfiscalyear - 1) Else Range("C1") = strmonth + ("_") + strfiscalyear End If If strckbx = True & strmonth

我试图使用一个“\u1”将来自用户输入表单的信息链接在一起,并有条件地从第二个变量中减去一个。以下是我所拥有的:

If strckbx = True & strmonth = "oct" Then
 Range("C1") = strmonth + "_" + (strfiscalyear - 1)
 Else
 Range("C1") = strmonth + ("_") + strfiscalyear
End If

If strckbx = True & strmonth = "Nov" Then
 Range("C1") = strmonth + ("_") + (strfiscalyear- 1)
 Else
 Range("C1") = strmonth + ("_") + strfiscalyear
End If

If strckbx = True & strmonth = "dec" Then
 Range("C1") = strmonth + ("_") + (strfiscalyear - 1)
 Else
 Range("C1") = strmonth + ("_") + strfiscalyear
End If

减号是以用户表单中的复选框为条件的。当我尝试运行或测试它时,我不断得到一个运行时错误13:类型不匹配。有人知道我能做什么吗?

应该是
,而不是
&

e、 g

&
用于VBA中的连接

请在此处阅读更多信息:


    • 不能从字符串中减去数字。这将导致类型不匹配

      改为这样做:
      cstr(cint(strfiscalyar)-1)

      也可以考虑使用<代码>和<代码>代替<代码>和<代码> < /P>范围(“C1”)= SrWORE和“^”和(StrufCalayle)- 1

      If strckbx = True And strmonth = "oct" Then