我正试图在另一个if else中做一个if else。但它没有If就给了我Else的错误。我有一个如果有,但VBA怎么没有看到它?
a = Sheet1.ComboBox1.value
If unit <> a Then
If a = "mils" Then
Set cx = Sheet9.range("E2", Sheet9.range("E2").End(xlDown))
For Each rng In cx
rng.value = rng.value * y
Else
Set cx = Sheet9.range("E2", Sheet9.range("E2").End(xlDown))
For Each rng In cx
rng.value = rng.value / y
End If
End If
答案 0 :(得分:3)
您错过了Next
的{{1}},这使For
和IF
块交错。
For
答案 1 :(得分:0)
这是for each
语句
以下是VBA中For Each
循环的语法:
For Each element In Group
[statement 1]
[statement 2]
....
[statement n]
[Exit For]
[statement 11]
[statement 22]
Next //you are missing this line in your coding