0
我複製並粘貼從我的copySheet(列A和B)2列到pasteSheet(列A和B)第一個空行與此代碼;基於ID更新對行
Set copySheet = Worksheets("copySheet")
Set pasteSheet = Worksheets("pasteSheet")
lRow = copySheet.Cells(copySheet.Rows.Count, 1).End(xlUp).Row
With copySheet.Range("A1:A" & lRow)
pasteSheet.Cells(Rows.Count, "A").End(xlUp).Offset(1, 0).Resize(.Rows.Count, .Columns.Count) = .Value
End With
lRow = copySheet.Cells(copySheet.Rows.Count, 1).End(xlUp).Row
With copySheet.Range("B1:B" & lRow)
pasteSheet.Cells(Rows.Count, "B").End(xlUp).Offset(1,0).Resize(.Rows.Count, .Columns.Count) = .Value
End Sub
欲編碼的算法來檢查,如果在copySheet的列A中的任何電池具有與pasteSheets值相同的值,然後在pasteSheet列B的單元將具有的列B的值copysheet。總結:我不得不在每張表中列;列A有ID號,列B有名稱。在複製/粘貼操作期間,如果copysheet的列A具有與PasteSheet的列A中相同的id號,則該對id(copySheet的列B)將被覆蓋到列B中的pasteSheet的對應單元。
With這個,我會根據ID(列A)更新產品的數量(B列)。我希望我的問題很明確,並希望得到建議。
謝謝!只是快速的問題; v = copySheet.Cells(rw,1).Value; 1表示這裏是正確的?如果我會有一個名爲BX的列,那麼它會是corrosponding號碼呢? –
您可以使用數字或字母作爲Cells()的第二個參數。所以細胞(rw,1)和細胞(rw,「A」)指的是同一個細胞。 –