我对VBA的经验很少,但有其他编程经验。我有一个循环,可以将正确的数据写入正确的位置。但是,循环后的代码没有完成。我相信我没有正确地终止循环,但还没有弄清楚如何让它结束。
Dim i As Integer
Dim j As Integer
Dim TestInfo, PatID, TestCode, OAValue As String
For i = 2 To 25
Columns(i).Select
If Cells(1, i).Value = 0 Then
End
Else
For j = 2 To 52
Rows(j).Select
PatID = Cells(1, i).Value
TestCode = Cells(j, 1).Value
OAValue = Cells(j, i).Value
TestInfo = PatID & "," & TestCode & "," & OAValue
stream.WriteLine TestInfo
Next j
End
End If
Next i
End
stream.Close
ActiveWorkbook.Close savechanges:=False
非常感谢任何帮助。 提前谢谢。
答案 0 :(得分:0)
使用
Exit For
而不是结束从循环中断。
你也可以删除列(i)。选择和行(j)。选择 - 它们正在减慢执行速度而没有任何利润。