Copy/Paste with link

huangapple go评论70阅读模式
英文:

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

huangapple
  • 本文由 发表于 2020年1月3日 22:41:35
  • 转载请务必保留本文链接:https://go.coder-hub.com/59580492.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定