Excel 2010 粘贴值
Dim ws As Worksheet, wbREF As Workbook
Set ws = ActiveSheet
Set wbREF = Workbooks.Open("ALSP.xls") 'you may want to put the full path here
Range("B7:L61").Copy ws.Range("N7") 'copy to original sheet
wbREF.Close False
Set ws = ActiveSheet
Set wbREF = Workbooks.Open("FLSP.xls") 'you may want to put the full path here
Range("B7:L61").Copy ws.Range("Z7") 'copy to original sheet
wbREF.Close False
Set ws = ActiveSheet
Set wbREF = Workbooks.Open("GASP.xls") 'you may want to put the full path here
Range("B7:L61").Copy ws.Range("AL7") 'copy to original sheet
wbREF.Close False
我现在正在使用这个宏,效果很好。我的问题是关于工作簿“GASP”,其中有公式。该宏不会复制我需要的值。任何人都可以建议解决方法。谢谢
Dim ws As Worksheet, wbREF As Workbook
Set ws = ActiveSheet
Set wbREF = Workbooks.Open("ALSP.xls") 'you may want to put the full path here
Range("B7:L61").Copy ws.Range("N7") 'copy to original sheet
wbREF.Close False
Set ws = ActiveSheet
Set wbREF = Workbooks.Open("FLSP.xls") 'you may want to put the full path here
Range("B7:L61").Copy ws.Range("Z7") 'copy to original sheet
wbREF.Close False
Set ws = ActiveSheet
Set wbREF = Workbooks.Open("GASP.xls") 'you may want to put the full path here
Range("B7:L61").Copy ws.Range("AL7") 'copy to original sheet
wbREF.Close False
I am now using this macro which works great. My question is for the workbook "GASP" which has formulas in it. This marco does not copy over the values which I need. Can anyone suggest a work around. Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
首先,您实际上只需要在宏顶部出现一次这一行:
接下来,要仅复制值,您需要切换到两行复制/粘贴命令:
First, you only really need this one line once at the top of your macro:
Next, to copy VALUES only, you need to switch to a two-line copy/paste command:
我认为你想要做的是让宏复制值而不仅仅是公式。检查下面的代码
同时确保 excel 已打开自动计算。您可以在“公式”功能区中检查这一点。最后要注意的一件事是,您需要小心验证您的推荐人。每当您调用“Range”函数时,明智的做法是指定包含该范围的工作簿和工作表。像这样:
或者
I think what you want to do is have the macro copy the values and not just the formulas. Check the out code below
Also make sure excel has Automatic Calculation turned on. You can check this in the "Formulas" Ribbon. One final thing to be aware of is that you need to be careful about qualifying your references. Whenever you call the "Range" function, it is wise to specify the workbook and the worksheet on which that range is contained. Like this:
or