Skip to content

Instantly share code, notes, and snippets.

@Tomokatsu-Sakamoto
Created February 18, 2022 05:27
Show Gist options
  • Save Tomokatsu-Sakamoto/2140da20752eb434d4c57fd9298784cb to your computer and use it in GitHub Desktop.
Save Tomokatsu-Sakamoto/2140da20752eb434d4c57fd9298784cb to your computer and use it in GitHub Desktop.
var value;
function myFunction( ) {
var sheet = SpreadsheetApp.getActive( ); // スプレッドシート
var cellNow = sheet.getCurrentCell( ).getValue( );
Logger.log( 'セルの内容 : [' + cellNow + ']' );
value = Number( PropertiesService.getDocumentProperties( ).getProperty( 'CELL_VALUE' ) );
Logger.log( '変数の内容1 : [' + value + '] , [' + Number( cellNow ) + ']' );
if ( value == undefined ) {
value = 0;
Logger.log( '変数の内容1 : [' + value + '] , [' + Number( cellNow ) + ']' );
}
value = value + Number( cellNow );
Logger.log( '変数の内容2 : [' + value + ']' );
sheet.getCurrentCell( ).setValue( cellNow );
PropertiesService.getDocumentProperties( ).setProperty( 'CELL_VALUE', value );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment