简体   繁体   中英

Appending dynamic values to cell in google sheets

I have a cell (G7) that is dynamically linked to a website with importHTML, and it has number that is updated periodically. Is there a way to store the current value of that dynamic cell and add it to another cell, and the keep doing that every time it changes? Cell G7 is my dynamic number and Cell E2 where I want to keep appending changes to G7. So if right now G7 is $16.28, I want to store that in E2, and then let's say a few months from now G7 updates to $14.5, then I want it to add $14.5 to the $16.28 in cell E2 rather than replace it. So the new number upon updating G7 should be $30.78. Would I have to make another tab and store each iteration of G7 into a list and add them together with SUM in E2? How can I store the number in G7 when certain conditions are met use dates from cells C7, H7, and I7 automatically?

An example of a date condition being if C7<= H7, and I7 is equal to Today's date then append this number from G7 to E7.

Is there another way of doing this without making a history list in another sheet? In a scripting language I think this would be written as E2+=G7. While G7 is constantly changing it is being appended to E2.

Here is a Demo I made of the sheet im working on. https://docs.google.com/spreadsheets/d/1Wk1kMGeZuVEcSdsnXnGIzdwPHLqYKoyqlD1yYcGXxXs/edit?usp=sharing

Simple Trigger onEdit(e) runs when a user changes a value in a spreadsheet

The onEdit event trigger has an object passed by parameter that you can use depending on the Google Product used, for instance, Spreadsheet events , where the e.source object represents the Google Sheets file to which the script is bound.

For example:

function onEdit(e){
  // Set a comment on the edited cell to indicate when it was changed.
  var range = e.range;
  range.setNote('Last modified: ' + new Date());
}

By having the code above, when a change is made to a single cell, this code runs and sets a note every time the cell is changed/saved.

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