简体   繁体   English

如何仅将单元格值复制到其他工作表中的另一个单元格

[英]How to copy cell value ONLY to another cell in other worksheet

In order to bypass circular reference in excel, I'm thinking to copy and paste the calculated value (ONLY the value) to another cell in another worksheet every time the value is recalculated.为了绕过excel中的循环引用,每次重新计算值时,我都想将计算出的值(仅值)复制并粘贴到另一个工作表中的另一个单元格中。 I guess it's possible only by VBA.我想只有通过 VBA 才有可能。 Unfortunately, I could not come up with any code that worked for me.不幸的是,我无法想出任何对我有用的代码。 I'll be happy to have ideas.我会很高兴有想法。 Thank you.谢谢你。

[edited] the code I tried: [编辑]我试过的代码:

Sheets("Sheet1").Range("A1").MergeArea.Copy
Sheets("Sheet2").Range("B2").PasteSpecial xlPasteValues

Paste this code into the code window for "Sheet1"将此代码粘贴到“Sheet1”的代码窗口中

Option Explicit

Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Address = "$A$1" Then
        Sheets("Sheet2").Range("B2").Value = Target.Value
    End If
End Sub

this code will run anytime there is a change made on "Sheet1" and will place only the value (not the formula) into the cell "B2" on "Sheet2"此代码将在“Sheet1”上发生更改时运行,并且只会将值(而不是公式)放入“Sheet2”上的单元格“B2”中

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

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