Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/webpack/2.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 XLPaste值不反映复制的内容_Vba_Excel - Fatal编程技术网

Vba XLPaste值不反映复制的内容

Vba XLPaste值不反映复制的内容,vba,excel,Vba,Excel,我试图将某个范围上的值复制到另一个范围,但xlPastValues函数没有反映我复制的内容。没有错误,它只是在F6my range上显示空白单元格。请帮忙 With Worksheets(4) '[D4] Main date Worksheets(4).[J1].Value = Worksheets(1).[D4] '[J6:J31] holds formulas to calculate certain dates Worksheets(4).[J6:J

我试图将某个范围上的值复制到另一个范围,但
xlPastValues
函数没有反映我复制的内容。没有错误,它只是在
F6
my range上显示空白单元格。请帮忙

    With Worksheets(4)
    '[D4] Main date
    Worksheets(4).[J1].Value = Worksheets(1).[D4]
    '[J6:J31] holds formulas to calculate certain dates
    Worksheets(4).[J6:J31].Copy
    Worksheets(4).[F6].PasteSpecial Paste:=xlPasteValues
    Application.CutCopyMode = False
End With

可能是您的公式返回了一些“零”日期,“F6:F31”单元格的格式为“#”,因此您什么也看不到

否则,请尝试以下仅粘贴值的替代方法:

With Worksheets(4)
    '[D4] Main date
    .[J1].value = Worksheets(1).[D4]
    '[J6:J31] holds formulas to calculate certain dates
    With .[J6:J31] '<--| reference "source" range
        .Offset(, -4).value = .value '<--| "destination" range is 4 columns left of the "source" one
    End With
End With
与工作表(4)
“[D4]主要日期
[J1]。值=工作表(1)。[D4]
“[J6:J31]保存计算某些日期的公式

使用[J6:J31]'无法使用测试数据进行复制。
J6:J31
中有什么?这是一个用于计算日期的公式列表,我需要将值转移到
[F6:F31]
我已更新代码以反映我使用的确切代码。