简体   繁体   English

如果单元格值更改,请将值复制到另一个工作表

[英]If cell value changes, copy value to another worksheet

I created a project management template where I update the project's status on a regular basis. 我创建了一个项目管理模板,我定期更新项目的状态。

I want as soon as the cell value of one cell changes, the exact value will be copied to a cell on another worksheet. 我希望只要一个单元格的单元格值发生更改,就会将确切的值复制到另一个工作表上的单元格中。

If the cell value of the original cell is changed again (due to further project updates), I want the value to be copied again but below the previous copy, and so on. 如果原始单元格的单元格值再次更改(由于进一步的项目更新),我希望再次复制该值,但在前一个副本下面,依此类推。

As I would like to solve the problem on my own, I would be happy if you could give me some hints on how to proceed or where to look. 由于我想自己解决问题,如果你能给我一些关于如何继续或在哪里看的提示,我会很高兴。

You can use the Worksheet_Change() event. 您可以使用Worksheet_Change()事件。 For example, if the cell you're changing is A1 , test to see if the Target cell matches. 例如,如果您要更改的单元格是A1 ,请测试Target单元格是否匹配。 If so, determine the last used row on your destination sheet ( Sheet2 , below) and then assign the value. 如果是这样,请确定目标工作表上的最后一行( Sheet2 ,下面),然后分配该值。

Private Sub Worksheet_Change(ByVal Target As Range)

    If Target.Address = Range("A1").Address Then

        ' Get the last row on our destination sheet (using Sheet2, col A here)...
        Dim intLastRow As Long
        intLastRow = Sheet2.Cells(Sheet2.Rows.Count, "A").End(xlUp).Row

        ' Add our value to the next row...
        Sheet2.Cells(intLastRow + 1, "A") = Target.Value

    End If

End Sub

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

相关问题 如何仅将单元格值复制到其他工作表中的另一个单元格 - How to copy cell value ONLY to another cell in other worksheet 从另一个工作表复制等于单元格值的单元格 - Copy cell that equals cell value from another worksheet 将单元格值复制到其他工作表 - Copy cell value to a different worksheet 将一个单元格从一个工作表复制并粘贴到另一个工作表,然后乘以一个值 - copy and paste a cell from one worksheet to another and multiply it by a value 如何将单元格值复制并粘贴到同一工作簿中的另一个工作表 - How to copy and paste a cell value to another worksheet in the same workbook 如何通过匹配单元格值将范围复制并粘贴到另一个工作表 - How to copy and paste a range to another worksheet by matching a cell value 查找大于零的单元格值并复制到另一个工作表 - Find cell value greater than zero and copy to another worksheet 将单元格值转移到另一个工作表,而无需复制和粘贴? - Transfer cell value to another worksheet without copy and paste? 将单元格值从一个工作表复制到另一个工作表作为字符串 - copy a cell value from one worksheet to another as a string Excel 如果单元格值更新/更改,则将某些单元格值复制到另一个单元格/工作表 - Excel copy certain cell value to another cell/worksheet if cell value updated/changed
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM