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.
由于我想自己解决这个问题,如果你能给我一些关于如何进行或在哪里看的提示,我会很高兴的。
1 个解决方案
#1
3
You can use the Worksheet_Change()
event. For example, if the cell you're changing is A1
, test to see if the Target
cell matches. If so, determine the last used row on your destination sheet (Sheet2
, below) and then assign the value.
您可以使用Worksheet_Change()事件。例如,如果您要更改的单元格是A1,请测试目标单元格是否匹配。如果是这样,请确定目标工作表上的最后一行(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
#1
3
You can use the Worksheet_Change()
event. For example, if the cell you're changing is A1
, test to see if the Target
cell matches. If so, determine the last used row on your destination sheet (Sheet2
, below) and then assign the value.
您可以使用Worksheet_Change()事件。例如,如果您要更改的单元格是A1,请测试目标单元格是否匹配。如果是这样,请确定目标工作表上的最后一行(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