简体   繁体   English

将特定单元格数据复制到其他工作表的列中

[英]Copy a specific cell data into column of other sheet

I have two worksheets, named "Monthly" and "Index", in a workbook.我在一个工作簿中有两个工作表,名为“每月”和“索引”。

In Index, cell A1 will have a value after some calculations.在索引中,单元格 A1 经过一些计算后会有一个值。

I need to copy that value into "Monthly" Column "J".我需要将该值复制到“每月”列“J”中。

It shall be one by one using next row coding.应一一使用下一行编码。

Private Sub CommandButton2_Click()    
Dim i As Integer    
a = Worksheets("Monthly").Cells(Rows.Count, 1).End(xlUp).Row

For i = 2 To a    
    Range("K" & i).Copy Worksheets("Rule of 78").Range("D6")       
    'Range("A1").Offset(i - 1, 0).Copy Range("C1")    
    Range("I" & i).Copy Worksheets("Rule of 78").Range("D7")    
    Range("E" & i).Copy Worksheets("Rule of 78").Range("D8")    
    Range("A" & i).Copy Worksheets("Rule of 78").Range("D10")    
    Worksheets("Index").Range("C2").Copy " How to paste in Monthly sheet 
    column J, for every row, C2 is different"
Next i    

End Sub

Does "A1" have a formula? “A1”有公式吗? If so Excel is probably copying a formula, thus the error.如果是这样,Excel 可能正在复制公式,因此会出现错误。

Try:尝试:

Worksheets("Index").Range("A1").Copy
Worksheets("Monthly").Range("J" & i).PasteSpecial xlPasteValues

Edit: "A1" or "C2", I didn't get wich is giving you the error.编辑:“A1”或“C2”,我没有明白这是给你的错误。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM