繁体   English   中英

将公式复制/粘贴到另一个工作表

[英]copy/paste range with formula to another worksheet

我可能是愚蠢的,但我找不到一种简单的方法来将ws1中的一系列公式复制/粘贴到同一工作簿中的ws 我想避免沉重且不合适的Range.select select.copy Sheet("X").select ... story。

Set wb = Application.Workbooks("TT.xlsm")
Set ws = wb.Sheets("B")
Set ws1 = wb.Sheets("A")
<-----more code------->
 Sheets("A").Range(Cells(19, 1), Cells(41, 7)).Copy _
 Destination:=Sheets("B").Range(Cells(19, 1), Cells(41, 7))

返回错误。 如果我在With wb [code] End With之间捕获表达式,则相同。

 ws1.Range(Cells(19, 1), Cells(41, 7)).Formula = ws.Range(Cells(19, 1), Cells(41, 7)).Formula

返回Range方法失败, With wb与否。

我一定是想念一些东西,却看不出来! 谢谢你的光明。

您需要限定Cells对象( 等式的右侧

并且对于下面你需要激活ws1Sheets("A")

ws1.Activate
ws1.Range(Cells(19, 1), Cells(41, 7)).Formula = ws.Range(ws.Cells(19, 1), ws.Cells(41, 7)).Formula

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM