英文:
Copy/Paste with link
问题
我需要复制/粘贴一个带有链接的范围。
我知道要使用 Link:=True,但我不知道如何修改我的代码以实现这一点。
Sheets("Remboursement").Select '选择要复制的工作表
Dim maplage As Range '设置范围
Set maplage = Range("B2:E140").SpecialCells(xlCellTypeVisible) '仅复制可见单元格
maplage.Copy '复制范围
With Sheets("Controle")
.Activate '激活目标工作表
.Range("T3").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False '粘贴数值
End With
Set maplage = Nothing
我尝试了以下代码:
.Range("T3").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
但像往常一样,它不起作用。这是我在一个月内编写的长代码的一部分,所以我有点担心进行更改,这就是为什么我首先向您询问的原因。
英文:
I need to copy/paste a range with link.
I know it is with the Link:=True, but I Don't know how to modify my code to put it in.
Sheets("Remboursement").Select 'select the sheet to copy
Dim maplage As Range ' set range
Set maplage = Range("B2:E140").SpecialCells(xlCellTypeVisible)
maplage.Copy 'copy only visible cells
With Sheets("Controle")
.Activate ' activate the destination sheet
.Range("T3").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, _ 'paste the values
SkipBlanks:=False, Transpose:=False
End With
Set maplage = Nothing
I tried with :
.Range("T3").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
But as usual, it doesn't work. It is a part of a long code that I made in 1 month, so I am little bit afraid to change it, that's why I ask to you first.
答案1
得分: 3
Range.PasteSpecial
没有 Link
参数。
您正在寻找 Worksheet.Paste
:
这是少数情况之一,根据文档,您需要使用 Select
...
> 如果指定了此参数 (Link
),则不能使用 Destination
参数....
> 如果您不指定 Destination
参数,必须在使用此方法之前选择目标范围。
With Sheets("Controle")
.Activate
.Range("T3").Select
.Paste Link:=True
英文:
Range.PasteSpecial
does not have a Link
parameter.
You are looking for Worksheet.Paste
:
This is one of the few cases where you do need to Select
, per the documentation...
> If this argument (Link
) is specified, the Destination
argument cannot be used....
> If you don't specify the Destination
argument, you must select the destination range before you use this method.
With Sheets("Controle")
.Activate
.Range("T3").Select
.Paste Link:=True
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论