在vba上将值粘贴到另一个工作簿工作表时出现问题 [英] Problems pasting values on another workbook sheet on vba

查看:89
本文介绍了在vba上将值粘贴到另一个工作簿工作表时出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我具有以下代码,以便从工作簿中复制工作表并将其粘贴到另一个名为"Control_de_precios"的工作簿的工作表1上:

I have the following code in order to copy a sheet from a workbook and paste it on the sheet 1 of another workbook called "Control_de_precios":

Sub createSpreadSheet()

Set NewBook = Workbooks.Add
With NewBook
    .Title = "Control_precios_ddmmaaaa"
    .Subject = "Control_de_precios"
    .SaveAs Filename:="Control_precios_ddmmaaaa.xls"
End With

ThisWorkbook.Worksheets(1).Activate
Cells.Select
Selection.Copy
NewBook.Sheets(1).Activate
ActiveSheet(1).PasteSpecial xlPasteValues

End Sub

问题是我因为上一条指令而收到438错误,并且没有将值粘贴到新工作簿上.如果我将其更改为:

The problem is that I get the 438 error because the last instruction, and I don't get to paste values on my new workbook. If I change it for:

ActiveSheet(1).粘贴

我没有得到438错误,并且我粘贴了公式,但是我想粘贴值.

I don't get the 438 error, and I get to paste the formulas, but I want to paste the values.

¿有人可以帮我吗?

推荐答案

在活动表后添加范围引用.当我这样做时,它会起作用. ActiveSheet.Range("A1").PasteSpecial xlPasteValues

Add Range reference after the activesheet. When I do it this way it works. ActiveSheet.Range("A1").PasteSpecial xlPasteValues

这篇关于在vba上将值粘贴到另一个工作簿工作表时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆