运行VBA功能后,单元格中的#N / A.

时间:2016-06-16 09:57:21

标签: excel vba excel-vba

以下代码正常运行:它将一系列单元格从Sheet“GP Data”粘贴到“RAW”。代码的第一部分复制3x3的范围,后一代码复制4x4的范围。

早期代码执行时没有错误值,如下图所示。

然而,后一个代码执行所需的功能,但在粘贴数据后,总是在下一列中生成#N/A的单元格。

arrData = Sheets("GP Data").Range("U12:U14").Value
Set rngwrite = Nothing
Set rngwrite = Sheets("DZ").Range("A:A").Find(strdate, LookIn:=xlFormulas)
Do While rngwrite Is Nothing
    With Sheets("DZ").Range("A60000")
        .End(xlUp).AutoFill (.End(xlUp).Resize(2))
    End With
    Set rngwrite = Sheets("DZ").Range("A:A").Find(CDate(strdate),        LookIn:=xlFormulas)
Loop
rngwrite.Offset(, 1).Resize(, 3).Value = Application.Transpose(arrData)

arrData = Sheets("GP Data").Range("P12:R14").Value
'find get the first non-blank column in row 7 from right to left
Set rngwrite = Sheets("RAW").Range("IV7").End(xlToLeft).Offset(, 1)
'paste data
rngwrite.Resize(3, 3).Value = arrData
'drag dates across row 7
rngwrite.Offset(-1).Value = rngwrite.Offset(-1, -3).Value + 1

enter image description here

arrData = Sheets("GP Data").Range("U12:U15").Value
Set rngwrite = Nothing
Set rngwrite = Sheets("DZ").Range("A:A").Find(strdate, LookIn:=xlFormulas)
Do While rngwrite Is Nothing
    With Sheets("DZ").Range("A60000")
        .End(xlUp).AutoFill (.End(xlUp).Resize(2))
    End With
    Set rngwrite = Sheets("DZ").Range("A:A").Find(CDate(strdate), LookIn:=xlFormulas)
Loop
rngwrite.Offset(, 1).Resize(, 4).Value = Application.Transpose(arrData)

arrData = Sheets("GP Data").Range("P12:R15").Value
'find get the first non-blank column in row 7 from right to left
Set rngwrite = Sheets("RAW").Range("IV7").End(xlToLeft).Offset(, 1)
'paste data
rngwrite.Resize(4, 4).Value = arrData
'drag dates across row 7
rngwrite.Offset(-1).Value = rngwrite.Offset(-1, -3).Value + 1

0 个答案:

没有答案