VBA noob here,我需要從Sheet1中的特定列中複製並粘貼到基於Sheet2的特定列在2個條件下。詳細信息(它不是一個代碼):VBA代碼複製特定列中的單元格並將其粘貼(值)到另一個表單上的特定列中的單元格基於條件
i=2 & j=4
IF Sheet1.Cells(i, 4)<>0 and Sheet1.Cells(i, 49)<>0, Type "FK" in _
Sheet2.Cells(j, 1), Type "OF" in Sheet2.Cells(j + 1, 1), copy the following
Copy from **Sheet1** Paste in **Sheet2**
Cells(i, 52) Cells(j, 2)
Cells(i, 51) Cells(j, 3)
Cells(i, 4) Cells(j, 4)
Cells(i, 1) Cells(j, 5)
Cells(i, 53) Cells(j, 6)
Cells(i, 7) Cells(j, 7)
Cells(i, 10) Cells(j, 8)
Cells(i, 5) Cells(j, 9)
Cells(i, 6) Cells(j, 10)
Cells(i, 49) Cells(j, 11)
Cells(i, 50) Cells(j, 12)
Cells(i, 51) Cells(j, 13)
Cells(i, 51) Cells(j, 15)
Cells(i, 51) Cells(j, 16)
Cells(i, 51) Cells(j, 17)
Cells(i, 19) Cells(j + 1, 2)
Cells(i, 20) Cells(j + 1, 3)
Cells(i, 44) Cells(j + 1, 4)
Cells(i, 28) Cells(j + 1, 5)
Cells(i, 30) Cells(j + 1, 6)
Cells(i, 37) Cells(j + 1, 7)
Cells(i, 41) Cells(j + 1, 8)
Cells(i, 46) Cells(j + 1, 9)
Cells(i, 51) Cells(j + 1, 10)
Cells(i, 51) Cells(j + 1, 11)
next i
IF Sheet1.Cells(i, 4)<>0 and Sheet1.Cells(i, 49)=0, Type "OF" in _
Sheet2.Cells(j, 1), copy the following
Copy from **Sheet1** Paste in **Sheet2**
Cells(i, 19) Cells(j, 2)
Cells(i, 20) Cells(j, 3)
Cells(i, 44) Cells(j, 4)
Cells(i, 28) Cells(j, 5)
Cells(i, 30) Cells(j, 6)
Cells(i, 37) Cells(j, 7)
Cells(i, 41) Cells(j, 8)
Cells(i, 46) Cells(j, 9)
Cells(i, 51) Cells(j, 10)
Cells(i, 51) Cells(j, 11)
next i
Else, next i (start again for i + 1)
所以,基本上我想要做的是,如果條件1爲真,我會從1行數據複製並粘貼到另一接下來的2個空行片。同時,如果條件2爲真,則從1行復制數據並將其粘貼到另一個表單中的下一個空行。很抱歉,很長的文章,不知道任何其他方式來解釋它。謝謝大家。
您的代碼或不基於解釋的做事行列基礎? –