Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/28.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
插入复制的单元格值[vba]_Vba_Excel - Fatal编程技术网

插入复制的单元格值[vba]

插入复制的单元格值[vba],vba,excel,Vba,Excel,我有下面的代码,它复制一个特定的范围并粘贴到下一个工作表中,但它复制公式,我希望它只插入复制的行数和粘贴值 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("Dri

我有下面的代码,它复制一个特定的范围并粘贴到下一个工作表中,但它复制公式,我希望它只插入复制的行数和粘贴值

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

或者完全绕过剪贴板:

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

尝试使用以下类似的方法:

Sub create_payroll()
    'copies values from 'Driver' Worksheet (till last row) and pastes values into Invoice Data A14
    Dim LastRow As Long
    Dim srcRng As Range
    Application.ScreenUpdating = False

    With Sheets("Driver")
        LastRow = .Cells(.Rows.Count, "B").End(xlUp).Row
        Set srcRng = .Range("A3:H" & LastRow)
    End With


    With Sheets("Invoice Data")
        .Range("A14").Resize(srcRng.Rows.Count - 1, srcRng.Columns.Count).Insert shift:=xlDown
        .Range("A14").Resize(srcRng.Rows.Count, srcRng.Columns.Count).Value = srcRng.Value
    End With
End Sub

尝试使用以下类似的方法:

Sub create_payroll()
    'copies values from 'Driver' Worksheet (till last row) and pastes values into Invoice Data A14
    Dim LastRow As Long
    Dim srcRng As Range
    Application.ScreenUpdating = False

    With Sheets("Driver")
        LastRow = .Cells(.Rows.Count, "B").End(xlUp).Row
        Set srcRng = .Range("A3:H" & LastRow)
    End With


    With Sheets("Invoice Data")
        .Range("A14").Resize(srcRng.Rows.Count - 1, srcRng.Columns.Count).Insert shift:=xlDown
        .Range("A14").Resize(srcRng.Rows.Count, srcRng.Columns.Count).Value = srcRng.Value
    End With
End Sub

这可能会有帮助:可能会重复这可能会有帮助:可能会重复我需要它来插入行和粘贴值。我需要它来插入行和粘贴值。谢谢,效果很好。除非我有4行数据,它只粘贴3行,就像一个符咒。谢谢你,你工作得很好。除非我有4行数据,它只粘贴3行,就像一个符咒。谢谢你