将数据从一张表复制到任何其他工作表 [英] Copy paste data from one sheet to any other worksheet
本文介绍了将数据从一张表复制到任何其他工作表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这个代码,只将表1中的数据复制粘贴到表2.
Hi there I have this code which only copy-paste data from sheet 1 one to sheet 2.
Sub CopyPasteCumUpdate()
Dim rng As Range, inp As Range
'to remove 0 values that may be a result of a formula or direct entry.
Set rng = Nothing
Set inp = Selection
inp.Interior.ColorIndex = 37
On Error Resume Next
Set rng = Application.InputBox("Copy to", Type:=8)
On Error GoTo 0
If TypeName(rng) <> "Range" Then
MsgBox "Cancelled", vbInformation
Exit Sub
Else
rng.Parent.Activate
rng.Select
inp.Copy
Worksheets("Sheet2").Paste Link:=True
Application.CutCopyMode = 0
End If
End Sub
是否可以输入数据并将其粘贴到任何其他工作表,而无需硬编码?
Is it possible to input data and paste it to any other sheet without having to hard code?
推荐答案
从你的评论很容易。只需更改此部分:
From your comment that is easy. Just change this part:
rng.Parent.Activate
rng.Select
inp.Copy
Worksheets("Sheet2").Paste Link:=True
Application.CutCopyMode = 0
这样:
编辑:将链接粘贴到用户选择的范围内。
With this:
This is to paste the link in the range the user selected.
Application.Goto rng
inp.Copy
rng.Parent.Paste Link:=True
Application.CutCopyMode = 0
这篇关于将数据从一张表复制到任何其他工作表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文