我有以下代码,它复制某个范围并将其粘贴到下一个工作表中,但它复制公式,我希望它仅插入复制的行数并粘贴值。
Sub create_payroll()
'copies values from 'Driver' Worksheet (till last row) and pastes values into Invoice Data A14
Dim LastRow As Long
Application.ScreenUpdating = False
LastRow = Worksheets("Driver").Cells(Rows.Count, "B").End(xlUp).Row
Sheets("Driver").Range("A3:H" & LastRow).Copy
Sheets("Invoice Data").Range("A14").Insert xlShiftDown
最佳答案
或者完全绕过剪贴板:
Sheets("Invoice Data").Range("A14:H" & LastRow + 11).Value = Sheets("Driver").Range("A3:H" & LastRow).Value
要绕过剪贴板并插入行,请使用:
Sheets("Invoice Data").Rows("14:").Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Sheets("Invoice Data").Range("A14:H" & LastRow + 11).Value = Sheets("Driver").Range("A3:H" & LastRow).Value
关于vba - 插入复制的单元格值 [vba],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51176263/