SOLVED

Is it possible to record data in a cell whenever another specific data cell changes?

%3CLINGO-SUB%20id%3D%22lingo-sub-2193499%22%20slang%3D%22en-US%22%3EIs%20it%20possible%20to%20record%20data%20in%20a%20cell%20whenever%20another%20specific%20data%20cell%20changes%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2193499%22%20slang%3D%22en-US%22%3E%3CP%3EHello%2C%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3BI'm%20having%20trouble%20to%20find%20a%20way%20to%20copy%20in%20a%20cell%20the%20changes%20of%20another%20cell...%20let%20me%20explain%20myself.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIn%20one%20column%20I%20have%20the%20dates%20of%20%22Estimated%20time%20of%20Departures%22%20of%20the%20vessels%20(ETD).%3C%2FP%3E%3CP%3EAs%20today%20there%20have%20been%20a%20lot%20of%20changes%20of%20these%20dates%20due%20to%20the%20pandemic%20crisis%20I%20wan%20to%20record%20in%20another%20cell%20everytime%20a%20date%20changes.%20Example%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20will%20be%20using%26nbsp%3B%20(dd%2Fmm%2Fyyyy)%3C%2FP%3E%3CP%3Etoday%20is%2001.03.2021%20and%20the%20vessel%20is%20expected%20to%20depart%20on%2008.03.2021%3C%2FP%3E%3CP%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20A1%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20B1%3C%2FP%3E%3CP%3EETD%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%7C%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20Rollings%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%7C%3C%2FP%3E%3CP%3E08.03.2021%26nbsp%3B%20%7C%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%2008.03.2021%26nbsp%3B%20%26nbsp%3B%7C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Ethen%20%2C%20today%20is%2004.03.2021%20and%20the%20departure%20of%20the%20vessel%20was%20rolled%20to%20March%2012th%20.%20I%20will%20update%20the%20dates%20but%20I%20want%20B1%20to%20record%20the%20date%20if%20A1%20changes%20its%20value%20without%20deleting%20the%20last%20change...%20let%20me%20show%20you%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%20%26nbsp%3B%20A1%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20B1%3C%2FP%3E%3CP%3EETD%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%7C%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20Rollings%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%7C%3C%2FP%3E%3CP%3E12.03.2021%26nbsp%3B%20%7C%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%2008.03.2021%20%2F%2012.03.2021%26nbsp%3B%20%26nbsp%3B%7C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Enow%20it's%20March%205th%20and%20again%20the%20vessel%20was%20rolled%2C%20now%20to%20March%2015th%2C%20I%20want%20B1%20to%20do%20this%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%20A1%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20B1%3C%2FP%3E%3CP%3EETD%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%7C%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20Rollings%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%7C%3C%2FP%3E%3CP%3E15.03.2021%26nbsp%3B%20%7C%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%2008.03.2021%20%2F%2012.03.2021%20%2F%26nbsp%3B%20%26nbsp%3B15.03.2021%26nbsp%3B%20%7C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIn%20conclusion%2C%20I%20want%20A2%20to%20compare%20A1%20with%20the%20last%20change%20it%20did%20to%20itself.%20If%20it%20is%20different%20to%20the%20last%20input%20the%20cell%20will%20append%20it%20at%20the%20end.%3C%2FP%3E%3CP%3E%26nbsp%3Bis%20that%20possible%3F%20I%20don't%20want%20to%20add%20rows%26nbsp%3B%20or%20columns%20every%20time%20the%20cell%20changes.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20hope%20someone%20can%20help%20me%20with%20this.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2193499%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EExcel%20for%20web%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EMacros%20and%20VBA%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2193519%22%20slang%3D%22en-US%22%3ERe%3A%20Is%20it%20possible%20to%20record%20data%20in%20a%20cell%20whenever%20another%20specific%20data%20cell%20changes%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2193519%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F990621%22%20target%3D%22_blank%22%3E%40nahumjaime%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20following%20will%20work%20in%20the%20desktop%20versions%20of%20Excel%20(for%20Windows%20and%20MacOS)%2C%20not%20in%20the%20online%20version%2C%20nor%20in%20the%20versions%20for%20Android%20and%20iOS.%3C%2FP%3E%0A%3CP%3ELet's%20say%20you%20want%20to%20apply%20this%20to%20cells%20A2%3AA100.%3C%2FP%3E%0A%3CP%3ERight-click%20the%20sheet%20tab%20of%20the%20worksheet.%3C%2FP%3E%0A%3CP%3ESelect%20'View%20Code'%20from%20the%20context%20menu.%3C%2FP%3E%0A%3CP%3ECopy%20the%20following%20code%20into%20the%20worksheet%20module%3A%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-visual%22%3E%3CCODE%3EPrivate%20Sub%20Worksheet_Change(ByVal%20Target%20As%20Range)%0A%20%20%20%20Dim%20rng%20As%20Range%0A%20%20%20%20Dim%20dtm%20As%20String%0A%20%20%20%20If%20Not%20Intersect(Range(%22A2%3AA100%22)%2C%20Target)%20Is%20Nothing%20Then%0A%20%20%20%20%20%20%20%20Application.ScreenUpdating%20%3D%20False%0A%20%20%20%20%20%20%20%20Application.EnableEvents%20%3D%20False%0A%20%20%20%20%20%20%20%20For%20Each%20rng%20In%20Intersect(Range(%22A2%3AA100%22)%2C%20Target)%0A%20%20%20%20%20%20%20%20%20%20%20%20If%20IsDate(rng.Value)%20Then%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20dtm%20%3D%20Format(rng.Value%2C%20%22dd.mm.yyyy%22)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20If%20Not%20rng.Offset(0%2C%201).Value%20Like%20%22*%22%20%26amp%3B%20dtm%20Then%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20If%20rng.Offset(0%2C%201).Value%20%3D%20%22%22%20Then%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20rng.Offset(0%2C%201).Value%20%3D%20dtm%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20Else%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20rng.Offset(0%2C%201).Value%20%3D%20rng.Offset(0%2C%201).Value%20%26amp%3B%20%22%20%2F%20%22%20%26amp%3B%20dtm%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20End%20If%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20End%20If%0A%20%20%20%20%20%20%20%20%20%20%20%20End%20If%0A%20%20%20%20%20%20%20%20Next%20rng%0A%20%20%20%20%20%20%20%20Application.EnableEvents%20%3D%20True%0A%20%20%20%20%20%20%20%20Application.ScreenUpdating%20%3D%20True%0A%20%20%20%20End%20If%0AEnd%20Sub%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3ESwitch%20back%20to%20Excel.%3C%2FP%3E%0A%3CP%3ESave%20the%20workbook%20as%20a%20macro-enabled%20workbook%20(.xlsm).%3C%2FP%3E%0A%3CP%3EMake%20sure%20that%20you%20allow%20macros%20when%20you%20open%20the%20workbook.%3C%2FP%3E%3C%2FLINGO-BODY%3E
New Contributor

Hello, 

 

 I'm having trouble to find a way to copy in a cell the changes of another cell... let me explain myself.

 

In one column I have the dates of "Estimated time of Departures" of the vessels (ETD).

As today there have been a lot of changes of these dates due to the pandemic crisis I wan to record in another cell everytime a date changes. Example:

 

I will be using  (dd/mm/yyyy)

today is 01.03.2021 and the vessel is expected to depart on 08.03.2021

      A1                    B1

ETD             |      Rollings        |

08.03.2021  |      08.03.2021   |

 

then , today is 04.03.2021 and the departure of the vessel was rolled to March 12th . I will update the dates but I want B1 to record the date if A1 changes its value without deleting the last change... let me show you:

 

    A1                    B1

ETD             |      Rollings                            |

12.03.2021  |      08.03.2021 / 12.03.2021   |

 

now it's March 5th and again the vessel was rolled, now to March 15th, I want B1 to do this:

 

  A1                    B1

ETD             |      Rollings                                                  |

15.03.2021  |      08.03.2021 / 12.03.2021 /   15.03.2021  |

 

In conclusion, I want A2 to compare A1 with the last change it did to itself. If it is different to the last input the cell will append it at the end.

 is that possible? I don't want to add rows  or columns every time the cell changes.

 

I hope someone can help me with this.

 

Thanks!

 

 

 

4 Replies
best response confirmed by nahumjaime (New Contributor)
Solution

@nahumjaime 

The following will work in the desktop versions of Excel (for Windows and MacOS), not in the online version, nor in the versions for Android and iOS.

Let's say you want to apply this to cells A2:A100.

Right-click the sheet tab of the worksheet.

Select 'View Code' from the context menu.

Copy the following code into the worksheet module:

Private Sub Worksheet_Change(ByVal Target As Range)
    Dim rng As Range
    Dim dtm As String
    If Not Intersect(Range("A2:A100"), Target) Is Nothing Then
        Application.ScreenUpdating = False
        Application.EnableEvents = False
        For Each rng In Intersect(Range("A2:A100"), Target)
            If IsDate(rng.Value) Then
                dtm = Format(rng.Value, "dd.mm.yyyy")
                If Not rng.Offset(0, 1).Value Like "*" & dtm Then
                    If rng.Offset(0, 1).Value = "" Then
                       rng.Offset(0, 1).Value = dtm
                    Else
                       rng.Offset(0, 1).Value = rng.Offset(0, 1).Value & " / " & dtm
                    End If
                End If
            End If
        Next rng
        Application.EnableEvents = True
        Application.ScreenUpdating = True
    End If
End Sub

Switch back to Excel.

Save the workbook as a macro-enabled workbook (.xlsm).

Make sure that you allow macros when you open the workbook.

Hello @Hans Vogelaar.!!

 

 I'm working on a large company where we have a lot of lines of shipments. We are using Excel Online for updating the ETDs and recording on a column the rolling of these ETDs. I've been watching some videos of how to program a sheet on Excel Online using JS but is it possible to run this same program on Excel Online?

@nahumjaime 

VBA does not work in the online version.

I cannot help you with a script that works on the web, sorry.