我試圖通過兩個單獨的工作表(「Participaciones Bond」和「Participaciones VAL」)中的帳戶進行排序,並將兩張表中的客戶複製到工作表「resumen」和在一個但不是另一箇中的客戶放入另一個「resumen」列。找不到爲什麼VBA代碼沒有輸入If語句
在這兩張紙上覆制這些客戶的部分效果很好,但我無法弄清楚爲什麼第二個if語句不起作用。
'Patribond= i, patriVal= j
i = 5
j = 5
Do While Worksheets("Participaciones Bond ").Cells(i, "A") <> ""
j = 5
Do While Worksheets("Participaciones VAL ").Cells(j, "A") <> ""
If Worksheets("Participaciones Bond ").Cells(i, 1).Value = Worksheets("Participaciones VAL ").Cells(j, 1).Value Then
Worksheets("Participaciones Bond ").Activate
Sheets("Participaciones Bond ").Select
Worksheets("Participaciones Bond ").Rows(i).Copy Sheets("Resumen").Range("A1048576").End(xlUp).Offset(1, 0)
Exit Do
End If
j = j + 1
'personas en patribond que no aparecen en patrival'
If Worksheets("Participaciones VAL ").Cells(j, 1) = "" Then
Worksheets("Resumen").Activate
'Cells(3, "H").Value = "We got into the second IF"'
Worksheets("Participaciones Bond ").Activate
Range(Cells(i, "A"), Cells(i, "E")).Copy
Worksheets("Resumen").Activate
Range(Cells(i, "G"), Cells(i, "X")).Select
Worksheets("Resumen").Paste
End If
Loop
i = i + 1
Loop
你需要休息'j'? –
我相信我每次都需要重置J,因爲它是一個嵌套的DoWhile循環。附註 - 我的數據從第5行開始 –
無後顧之憂。我懷疑它有什麼關係,因爲我從來沒有進入第二個如果。 –