简体   繁体   English

将特定单元格从一个工作表复制并粘贴到另一个工作表

[英]Copy and Paste Specific Cells from one worksheet to another

I have a spreadsheet Sheet1 I have a row with some cell values as shown in Image 1. I am having a problem trying to copy and paste cells from one worksheet to another in excel. 我有一个电子表格Sheet1,其中一行包含一些单元格值,如图1所示。尝试将单元格中的单元格复制并粘贴到Excel中的另一个单元格时遇到问题。 As shown in the below Image 1, I have a row with values and I want to copy the cells from Sheet1 and paste it to Sheet2 as shown in Image 2. 如下面的图像1所示,我有一排带有值的行,我想从Sheet1复制单元格并将其粘贴到Sheet2,如图2所示。

图片1

图片2

Can anyone please tell me how to do that? 谁能告诉我该怎么做?

For the first cell on Sheet2, write: 对于Sheet2的第一个单元格,编写:

=Sheet1!A4

Then the other two as follows: 然后另两个如下:

=Sheet1!D4
=Sheet1!G4

That is, if you want to have the same values even if you update the ones on Sheet1. 也就是说,即使更新Sheet1上的值也要具有相同的值。 If not, perhaps you want vba code? 如果没有,也许您想要vba代码? Create a new module: 创建一个新模块:

sub copy()

dim sheet1 as Worksheet, sheet2 as Worksheet

sheet1 = Worksheets("Sheet1")
sheet2 = Worksheets("Sheet2")
sheet2.Cells(1,"A").Value=sheet1.Cells(4,"A").Value
sheet2.Cells(2,"A").Value=sheet1.Cells(4,"D").Value
sheet2.Cells(3,"A").Value=sheet1.Cells(4,"G").Value

end sub

Try this script. 试试这个脚本。

Sub CopyData1()
Dim cell As Range, rw As Long
rw = 2
For Each cell In ActiveSheet.Range("A1:H20")
If Not IsEmpty(cell) = True Then
Worksheets("Sheet2").Cells(rw, 1).Value = cell.Value
rw = rw + 1
End If
Next
End Sub

I'm assuming you have a sheet named 'Sheet2'. 我假设您有一个名为“ Sheet2”的工作表。 If not, just rename the sheet where you want the values copied to. 如果没有,只需重命名要将值复制到的工作表。

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

相关问题 从一行复制特定的单元格,然后粘贴到另一工作表的不同单元格中 - Copy specific cells from one row and paste into different cells on another worksheet 将特定的列从工作表复制/粘贴到另一个 - Copy/Paste Specific Columns from a Worksheet to another 从一个工作表复制并粘贴到另一个工作表的宏 - Macro to copy and paste from one worksheet to another 从一个工作表复制并粘贴到另一个 - Copy and Paste from one worksheet to another 将工作表从一个复制并粘贴到另一个 - Copy and paste worksheet from one to another 将粘贴范围从一个工作表复制到另一个 - Copy paste range from one worksheet to another 需要代码将特定值从工作表上的表格中的选定行复制并粘贴到另一个表格中的单元格 - Need code to copy and paste specific values from selected rows on a table on a worksheet to cells within a table on another 将单元格从一个工作表复制并重新格式化为另一工作表 - Copy and reformat cells from one worksheet to another Excel宏可将数据从一个工作表复制并粘贴到另一工作表 - Excel macro to copy and paste data from one worksheet to another worksheet 需要一个宏以根据单元格中的数据将一个工作表中的行中的特定单元格复制到另一工作表中的特定单元格 - Need a macro to copy specific cells from a row in one worksheet to a specific cells in another worksheet base upon a data in the cell
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM