VBA将值从一个工作表复制到另一个工作表,并插入指定的单元格

时间:2017-08-31 20:32:16

标签: excel excel-vba vba

我想将所有值从一个工作表复制到另一个工作表,并且它复制正常,但是对于一个单元格,它复制字符串为TRUE,我该如何修复它以及为什么会发生这种情况?

这是我的代码:

Sub Unos_povrata()

Dim rw As Long
Dim cl As Integer
Dim Dest As Range


cl = 1 ' A stupac

rw = ActiveWorkbook.Sheets("zbirna").Cells(65535, cl).End(xlUp).Row + 1

Set Dest = ActiveWorkbook.Sheets("zbirna").Cells(rw, cl + 66) 'F1
Dest.Value = ActiveWorkbook.Sheets("porudzbenica").Range("F1") '
Set Dest = ActiveWorkbook.Sheets("zbirna").Cells(rw, cl) 'A4
Dest.Value = ActiveWorkbook.Sheets("porudzbenica").Range("A23") '
Set Dest = ActiveWorkbook.Sheets("zbirna").Cells(rw, cl + 1) 'B4
Dest.Value = ActiveWorkbook.Sheets("porudzbenica").Range("B23") '

Set Dest = ActiveWorkbook.Sheets("zbirna").Cells(rw, cl + 65) 'AH4
Dest.Value = ActiveWorkbook.Sheets("porudzbenica").Range("AH23") '
Dest.Value = ActiveWorkbook.Sheets("porudzbenica").Range("C23:AH23").Select

    Selection.ClearContents

End Sub

此外,我必须提一下,如果我删除行

Dest.Value = ActiveWorkbook.Sheets("porudzbenica").Range("C23:AH23").Select

        Selection.ClearContents

比它复制正常值,但问题是当我想插入新的值行时,它会删除上一行。

0 个答案:

没有答案