Excel 中 VBA中运行这段 Do While Range("A1:A65536") <> "" 时 提示运行错误'13' 类型不匹配 是什么意思呢?意图:比较第i行的 单元格Bi 到 Ei 的值,找出最大值,然后根据得出的最大值的单元格代表的意义,将结果写在Fi 和 Gi 单元格上。
贴上原代码:Sub 比较取状态自动()
Do While Range("A1:A65536") <> "" '当A列单元格不等于空时,循环获取状态
Dim i&
For i = 2 To 65536
If Cells(i, "b") > Cells(i, "c") And Cells(i, "b") > Cells(i, "d") And Cells(i, "b") > Cells(i, "e") Then
Cells(i, 6) = "Bornege" '输出最大的值B,结果显示在F、G
Cells(i, 7) = "2OnCutDown"
Else
If Cells(i, "c") > Cells(i, "d") And Cells(i, "c") > Cells(i, "e") Then
Cells(i, 6) = "PutIn" '输出最大的值C,结果显示在F、G
Cells(i, 7) = "1OnBorn" 'C>E输出C
Else
If Cells(i, "d") > Cells(i, "e") Then
Cells(i, 6) = "Seach" '输出最大的值D,结果显示在F、G
Cells(i, 7) = "0OnPutIn" 'D>E时 直接输出最大的值D,结果显示在F、G
Else
Cells(i, 6) = "CutDown" '输出最大的值E,结果显示在F、G
Cells(i, 7) = "0OnPutIn"
End If
End If
End If
Next i
Loop
End Sub
按F8时运行到Do While时就报错了,请问各位大神是什么意思呢?怎么破
贴上原代码:Sub 比较取状态自动()
Do While Range("A1:A65536") <> "" '当A列单元格不等于空时,循环获取状态
Dim i&
For i = 2 To 65536
If Cells(i, "b") > Cells(i, "c") And Cells(i, "b") > Cells(i, "d") And Cells(i, "b") > Cells(i, "e") Then
Cells(i, 6) = "Bornege" '输出最大的值B,结果显示在F、G
Cells(i, 7) = "2OnCutDown"
Else
If Cells(i, "c") > Cells(i, "d") And Cells(i, "c") > Cells(i, "e") Then
Cells(i, 6) = "PutIn" '输出最大的值C,结果显示在F、G
Cells(i, 7) = "1OnBorn" 'C>E输出C
Else
If Cells(i, "d") > Cells(i, "e") Then
Cells(i, 6) = "Seach" '输出最大的值D,结果显示在F、G
Cells(i, 7) = "0OnPutIn" 'D>E时 直接输出最大的值D,结果显示在F、G
Else
Cells(i, 6) = "CutDown" '输出最大的值E,结果显示在F、G
Cells(i, 7) = "0OnPutIn"
End If
End If
End If
Next i
Loop
End Sub
按F8时运行到Do While时就报错了,请问各位大神是什么意思呢?怎么破
怎么破?
for i=1 to 65536
if cells(i,1)="" then exit for
''获取最大值
next2、你后面的代码也有问题。你最好查查worksheetfunction,里面有一个max函数