求:IF判断问题,头大。。。
如下代码中,不管判断条件是不是成立,else后面的语句都执行,求帮忙,哪位大侠有空,加我QQ,我演示一下给你看看,真是上大火了。。。Dim K As Integer
Dim J As Integer
Dim y As Integer
J = MSFlexGrid1.rows
K = 1
For M2 = 1 To MSFlexGrid1.rows - 2
'Text1 = I '测试用语句
For n = 1 To MSFlexGrid2.rows - 1
If MSFlexGrid1.TextMatrix(M2, 3) = MSFlexGrid2.TextMatrix(n, 3) Then
xlApp1.Worksheets(sheetname).Cells(K + 1, 1) = MSFlexGrid1.TextMatrix(M2, 0)
xlApp1.Worksheets(sheetname).Cells(K + 1, 2) = MSFlexGrid1.TextMatrix(M2, 1)
xlApp1.Worksheets(sheetname).Cells(K + 1, 3) = MSFlexGrid2.TextMatrix(n, 2) - MSFlexGrid1.TextMatrix(M2, 2)
xlApp1.Worksheets(sheetname).Cells(K + 1, 4) = MSFlexGrid1.TextMatrix(M2, 3)
Else
xlApp1.Worksheets(sheetname).Cells(J + 1, 1) = MSFlexGrid2.TextMatrix(M2, 0)
xlApp1.Worksheets(sheetname).Cells(J + 1, 2) = MSFlexGrid2.TextMatrix(M2, 1)
xlApp1.Worksheets(sheetname).Cells(J + 1, 3) = MSFlexGrid2.TextMatrix(M2, 2)
xlApp1.Worksheets(sheetname).Cells(J + 1, 4) = MSFlexGrid2.TextMatrix(M2, 3)
End If
Next n
K = K + 1
J = J + 1
Next M2