简体   繁体   中英

How to capture a cell value in Excel when a cell updated

I have a cell in Excel that gets updated on basis of RAND() function. Each time I update the cell, I want to capture the previous values in a separate column. So that I can compute mean later on.

How to achieve this??

Copy below into Worksheet module and change "A1" cell:

Private Sub Worksheet_Change(ByVal Target As Range)
    If Not (Intersect(Target, Range("A1")) Is Nothing) Then
    i = i + 1
    Worksheets("Sheet1").Cells(i, 2).Value = Worksheets("Sheet1").Cells(1, 1).Value
    End If
End Sub

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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