vba 将文本从一个工作簿复制到另一个

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12060125/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-11 17:25:23  来源:igfitidea点击:

Copy text from one workbook to another

excelvba

提问by Prem

I have an Excel workbook which contains an array of data.

我有一个 Excel 工作簿,其中包含一组数据。

I want to create test cases (Software testing) of another sheet by using the test data available in the first sheet.

我想使用第一张工作表中可用的测试数据创建另一张工作表的测试用例(软件测试)。

So the final sheet will have the combination of sentence and the first sheet test data.

所以最终的sheet会有sentence和第一张sheet test data的组合。

I'll put the sentence in but I need the basic skeleton code to go row by row and column by column to copy the data and paste.

我会把句子放进去,但我需要基本的骨架代码来逐行和逐列地复制数据并粘贴。

回答by yadutaf

Well, there are already questions related to this on SO. For example, here is snippet shamelessly stolen from Copy data from another Workbook through VBAand freely adapted

好吧,SO 上已经有与此相关的问题。例如,这里是通过 VBA 从另一个工作簿复制数据中无耻地窃取并自由改编的片段

Option Explicit
Sub test()
    Dim wb As Workbook

    'Set source workbook
    Set wb = ActiveWorkbook

    'For instance, copy data from a range in the first workbook to another range in the other workbook
    wb.Worksheets("Sheet2").Range("C3:D4").Value = wb.Worksheets("Sheet1").Range("A1:B2").Value
End Sub

The original answer was from user JMax

原始答案来自用户 JMax