excel中vba,写了如下程序,IF 语句前面两个可以执行,后边不能执行,怎么回事呢?

Forsubrow=1To10IfInStr(1,Cells(i+subrow,1),"ShipName")ThenWorksheets("Data").Cells(j,... For subrow = 1 To 10

If InStr(1, Cells(i + subrow, 1), "Ship Name") Then
Worksheets("Data").Cells(j, 7) = Split(Cells(i + subrow, 1), "Ship Name")(1)
b = Worksheets("Data").Cells(j, 7)
Worksheets("Data").Cells(j, 7) = Split(b, "Flag")(0)
End If
If InStr(1, Cells(i + subrow, 1), "Flag") Then Worksheets("Data").Cells(j, 8) = Split(Cells(i + subrow, 1), "Flag")(1)
If InStr(1, Cells(i + subrow, 1), "Ship Type") Then
Worksheets("Data").Cells(j, 9) = Split(Cells(i + subrow, 1), "Ship Type")(1)
c = Worksheets("Data").Cells(j, 9)
Worksheets("Data").Cells(j, 9) = Split(c, "Year of Build")(0)
Worksheets("Data").Cells(j, 10) = Right(Cells(i + subrow, 1), 5)
End If
If InStr(1, Cells(i + subrow), "GT") Then
Worksheets("Data").Cells(j, 11) = Split(Cells(i + subrow, 1), "GT")(1)
d = Worksheets("Data").Cells(j, 11)
Worksheets("Data").Cells(j, 11) = Split(d, "DWT")(0)
End If
If InStr(1, Cells(i + subrow), "DWT") Then Worksheets("Data").Cells(j, 12) = mid(Cells(i + subrow, 1), InStr(InStr(1, Cells(i + subrow, 1), " ") + 1, Cells(i + subrow, 1), " ") + 1, InStr(InStr(InStr(1, Cells(i + subrow, 1), " ") + 1, Cells(i + subrow, 1), " ") + 1, Cells(i + subrow, 1), " ") - InStr(InStr(1, Cells(i + subrow, 1), " ") + 1, Cells(i + subrow, 1), " ") - 1)
If InStr(1, Cells(i + subrow), "Classification") Then
Worksheets("Data").Cells(j, 13) = Split(Cells(i + subrow, 1), "Classification")(1)
e = Worksheets("Data").Cells(j, 13)
Worksheets("Data").Cells(j, 13) = Split(e, "Ship Status")(0)
End If
If InStr(1, Cells(i + subrow), "Ship Status") Then Worksheets("Data").Cells(j, 14) = Split(Cells(i + subrow, 1), "Ship Status")(1)
If InStr(1, Cells(i + subrow), "Owner") Then Worksheets("Data").Cells(j, 15) = Split(Cells(i + subrow, 1), "Owner")(1)
Next
展开
 我来答
l7722526
2017-11-24 · TA获得超过2.7万个赞
知道大有可为答主
回答量:2.8万
采纳率:84%
帮助的人:3818万
展开全部
1.如果if条件成立,当然不会执行else子句。而会执行if子句

2.如果误将if条件中的相等操作符==误写成了赋值号=,而且=后面的值不是0,那么这个条件将一直成立,所以不会执行else子句

3.如果else后面有多条执行语句,而又没有加上括号,那么当if条件不成立时只会执行else后面的第一条语句,其它的语句不在else范围内,不管条件是否成立,它们都会执行。

4.如果根本没有else子句,那么...
追问
是前三个if语句可以执行,后边的if就没办法执行了
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式