[英]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所示。
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.