我有一個代碼從工作簿A中的特定工作表中選擇所有數據(在代碼中名稱爲'fn')並將其複製到工作簿B中的特定工作表中。我想要做的是僅貼上值,即貼,同時保持/轉換(到)過去片表的格式從複印紙上覆制的值,這裏是我的代碼 -使用vba粘貼值
Set copySheet = copyBook.Sheets(fn) 'Points to the sheet in the raw data file
Set pasteBook = ThisWorkbook 'Sets the file where we are supposed to paste to as the template file
Application.DisplayAlerts = False
Set pasteSheet = pasteBook.Sheets("Transaction") 'Points to the Transaction sheet on the template
lastRow = copySheet.Cells(Rows.Count, 1).End(xlUp).row 'Computes the last row on the raw data file
'Copies raw data to tab/sheet in template
copySheet.Activate
Application.ScreenUpdating = False
For column = 1 To 27
For row = 2 To lastRow
cp = copySheet.Cells(row, column)
pasteSheet.Cells(row + 211, column).Value = cp
Next
Next
Application.ScreenUpdating = True
copyBook.Close 'Closes the raw data file
End If
注 - 我真的喜歡這我只是對上面的代碼做了一些小改動,而不是完全製作其他代碼。謝謝!
你爲什麼循環? Wy不會複製並一次性完成粘貼操作? – 2014-10-27 16:02:06
你能告訴我怎麼做:)(如在代碼本身) – 2014-10-27 16:18:59
我可以但爲什麼你不記錄一個宏,並嘗試爲自己:) – 2014-10-27 16:33:27