在Excelmacros中循环
我正在尝试使用循环编写一个excelmacros,通过两列date,比较Excel中的date,如果date相同,则replace另一列中的某些值。
这是我的excel代码,有人能告诉我什么是错的吗? 我不断收到错误循环。
Sub automatic_replace_using_do_while_loop() Dim A As Integer, H As Integer A = 1 H = 1 Do While H < 1186 If Cells(A, 1).Value = Cells(H, 8).Value Then Cells(H, 6).Value = Cells(i, 11) H = H + 1 A = A + 1 Else H = H + 1 Loop End Sub
谢谢!
这不是我想要匹配date的方式,但是你永远不会结束你的If语句。
Do While H < 1186 If Cells(A, 1).Value = Cells(H, 8).Value Then Cells(H, 6).Value = Cells(i, 11) H = H + 1 A = A + 1 Else H = H + 1 END IF Loop
我不知道我在哪里发挥作用。 我想你的意思
Cells(H, 6).Value = Cells(A, 11)