我现在正在寻找半小时的修复。我有3个可能的值(低,中和高),我希望d是从1到3的值。运行脚本时出错。
Sub GetStructure()
Dim d As Integer
Dim i As Integer
Dim z As Integer
Dim k As Integer
Dim o As Integer
Dim o2 As Integer
i = Worksheets("Control").Cells(14, 2).Value
d = Worksheets("Control").Cells(9, 2).Value
If d = "High" Then
d = 3
End If
If d = "Mid" Then
d = 2
End If
If d = "Low" Then
d = 1
End If
答案 0 :(得分:3)
您定义Dim d As Integer
整数是一个数字。如果您编写If d = "High"
,则将整数与字符串
因此,定义另一个变量Dim v As String
,然后您可以指定v = Worksheets("Control").Cells(9, 2).Value
并在If v = "High" Then
处查看所有案例。