剪切/粘贴粘贴特殊

时间:2020-06-07 01:36:38

标签: excel vba

尝试剪切并粘贴范围时出现1004错误

axios.get('http://localhost:5000/users/carProducts/'+ID.userid)
            .then(res =>{
                console.log('data '+res.data)
            })
            .catch(error => console.log(error));

基本上,复制的值不会保留在剪贴板中,我也不知道为什么?

1 个答案:

答案 0 :(得分:2)

Cut方法不适用于PasteSpecial。它需要一个Deestination

Sub TEST_Code()
    ' 045

    ' you must specify the data type for each variable(!)
    Dim wsMRU As Worksheet, wsCov As Worksheet

    Set wsCov = ThisWorkbook.Worksheets("Cover Page")
    Set wsMRU = ThisWorkbook.Worksheets("MRU Calcs")

    With wsMRU
        .Range("A4").CurrentRegion.Cut Destination:=.Cells(4, "B")
    End With
End Sub

我建议使用寻址单元格的语法来寻址单元格,并将寻址范围的语法限制为单元格的地址范围。这意味着.Cells(4, "A").CurrentRegion.Cut Destination:=.Cells(4, "B")