How to increase i to next call?How To Use an Apps Script To “Copy-PasteValue” Dynamic Data In a Google Spreadsheet at a given time?Retrieve row from a table (with a specific value) and insert specific row to a new sheetHow to transform all data in sheet to values - google spreadsheetsIncreasing value of cell in google sheetsCopy data from one sheet to another; creating a table with the copied data in the target sheetGoogle Spreadsheet - How to copy cell data from one sheet to a cell in another sheet?Google Apps Script code to set value in the next blank rowCopy cells to another sheet when values increaseTransfer google sheet rows to another sheet based on cellGoogle spreadsheet script - move value to specific cell
Adjective for 'made of pus' or 'corrupted by pus' or something of something of pus
Journal standards vs. personal standards
sorting 4 numbers using Min - Max boxes
Sacrifice blocking creature before damage is dealt no longer working (MtG Arena)?
Can European countries bypass the EU and make their own individual trade deal with the U.S.?
Do home values typically rise and fall at a consistent percent?
Is is okay to submit a paper from a master's thesis without informing the advisor?
Why do I need two parameters in an HTTP parameter pollution attack?
How did installing this RPM create a file?
What kind of jet plane is this?
How can I tell what kind of genitals people have without gender?
How do I tell the reader that my character is autistic in Fantasy?
Could human civilization live 150 years in a nuclear-powered aircraft carrier colony without resorting to mass killing/ cannibalism?
How to get a character's limb regrown at 3rd level?
What is "oversubscription" in Networking?
Is there reliable evidence that depleted uranium from the 1999 NATO bombing is causing cancer in Serbia?
Can one use the present progressive or gerund like an adjective?
How do I organize members in a struct to waste the least space on alignment?
Warnings of R. Chaim Vital
How do I ensure my employees don't abuse my flexible work hours policy?
How Do I Know When I am in Private Mode?
Does a return economy-class seat between London and San Francisco release 5.28 tonnes of CO2 equivalents?
Comment traduire « That screams X »
Why would anyone even use a Portkey?
How to increase i to next call?
How To Use an Apps Script To “Copy-PasteValue” Dynamic Data In a Google Spreadsheet at a given time?Retrieve row from a table (with a specific value) and insert specific row to a new sheetHow to transform all data in sheet to values - google spreadsheetsIncreasing value of cell in google sheetsCopy data from one sheet to another; creating a table with the copied data in the target sheetGoogle Spreadsheet - How to copy cell data from one sheet to a cell in another sheet?Google Apps Script code to set value in the next blank rowCopy cells to another sheet when values increaseTransfer google sheet rows to another sheet based on cellGoogle spreadsheet script - move value to specific cell
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
Every celltest() function run, I want to increase i value
function cell_test ()
var i=8 ;
var ss = SpreadsheetApp.getActiveSpreadsheet ();
var source = ss.getRange ("A!C1");
var destSheet = ss.getSheetByName("B");
var destRange = destSheet.getRange(i,2);
source.copyTo (destRange, contentsOnly: true);
This code works as below...
When it calls cell_test (), it copy value from A!C1 and paste it at B sheet (8.2) cell position(i=8).
Next time call, I want to increase i value +1 and paste it to (9.2) cell position (i=9).
How to increase i values every cell_test ()?
Please help me out.
Thank you
google-apps-script google-sheets
add a comment |
Every celltest() function run, I want to increase i value
function cell_test ()
var i=8 ;
var ss = SpreadsheetApp.getActiveSpreadsheet ();
var source = ss.getRange ("A!C1");
var destSheet = ss.getSheetByName("B");
var destRange = destSheet.getRange(i,2);
source.copyTo (destRange, contentsOnly: true);
This code works as below...
When it calls cell_test (), it copy value from A!C1 and paste it at B sheet (8.2) cell position(i=8).
Next time call, I want to increase i value +1 and paste it to (9.2) cell position (i=9).
How to increase i values every cell_test ()?
Please help me out.
Thank you
google-apps-script google-sheets
What is "i"? Always 8 when you open the spreadsheet? The first empty row of B? And how is cell_test run, from menu, custom formula, onEdit?
– TheWizEd
Mar 25 at 14:22
the target cell is B sheet (8.2) which i want to paste. so i give i value to 8.Then i will paste value to B sheet (9.2).
– SY Moon
Mar 25 at 14:35
You haven't answered my questions.
– TheWizEd
Mar 25 at 17:05
add a comment |
Every celltest() function run, I want to increase i value
function cell_test ()
var i=8 ;
var ss = SpreadsheetApp.getActiveSpreadsheet ();
var source = ss.getRange ("A!C1");
var destSheet = ss.getSheetByName("B");
var destRange = destSheet.getRange(i,2);
source.copyTo (destRange, contentsOnly: true);
This code works as below...
When it calls cell_test (), it copy value from A!C1 and paste it at B sheet (8.2) cell position(i=8).
Next time call, I want to increase i value +1 and paste it to (9.2) cell position (i=9).
How to increase i values every cell_test ()?
Please help me out.
Thank you
google-apps-script google-sheets
Every celltest() function run, I want to increase i value
function cell_test ()
var i=8 ;
var ss = SpreadsheetApp.getActiveSpreadsheet ();
var source = ss.getRange ("A!C1");
var destSheet = ss.getSheetByName("B");
var destRange = destSheet.getRange(i,2);
source.copyTo (destRange, contentsOnly: true);
This code works as below...
When it calls cell_test (), it copy value from A!C1 and paste it at B sheet (8.2) cell position(i=8).
Next time call, I want to increase i value +1 and paste it to (9.2) cell position (i=9).
How to increase i values every cell_test ()?
Please help me out.
Thank you
google-apps-script google-sheets
google-apps-script google-sheets
asked Mar 25 at 14:08
SY MoonSY Moon
13 bronze badges
13 bronze badges
What is "i"? Always 8 when you open the spreadsheet? The first empty row of B? And how is cell_test run, from menu, custom formula, onEdit?
– TheWizEd
Mar 25 at 14:22
the target cell is B sheet (8.2) which i want to paste. so i give i value to 8.Then i will paste value to B sheet (9.2).
– SY Moon
Mar 25 at 14:35
You haven't answered my questions.
– TheWizEd
Mar 25 at 17:05
add a comment |
What is "i"? Always 8 when you open the spreadsheet? The first empty row of B? And how is cell_test run, from menu, custom formula, onEdit?
– TheWizEd
Mar 25 at 14:22
the target cell is B sheet (8.2) which i want to paste. so i give i value to 8.Then i will paste value to B sheet (9.2).
– SY Moon
Mar 25 at 14:35
You haven't answered my questions.
– TheWizEd
Mar 25 at 17:05
What is "i"? Always 8 when you open the spreadsheet? The first empty row of B? And how is cell_test run, from menu, custom formula, onEdit?
– TheWizEd
Mar 25 at 14:22
What is "i"? Always 8 when you open the spreadsheet? The first empty row of B? And how is cell_test run, from menu, custom formula, onEdit?
– TheWizEd
Mar 25 at 14:22
the target cell is B sheet (8.2) which i want to paste. so i give i value to 8.Then i will paste value to B sheet (9.2).
– SY Moon
Mar 25 at 14:35
the target cell is B sheet (8.2) which i want to paste. so i give i value to 8.Then i will paste value to B sheet (9.2).
– SY Moon
Mar 25 at 14:35
You haven't answered my questions.
– TheWizEd
Mar 25 at 17:05
You haven't answered my questions.
– TheWizEd
Mar 25 at 17:05
add a comment |
3 Answers
3
active
oldest
votes
You can make i a function parameter and call the function from a for loop:
function main()
var startRow = 8;
var endRow = 10;
for(var i=startRow; i<=endRow; i++)
cell_test(i);
function cell_test(i)
var ss = SpreadsheetApp.getActiveSpreadsheet ();
var source = ss.getRange ("A!C1");
var destSheet = ss.getSheetByName("B");
var destRange = destSheet.getRange(i,2);
source.copyTo (destRange, contentsOnly: true);
This will copy the content of cell A!C1 to cell B!B8, B!B9 and B!B10.
add a comment |
I don't know if i needs to be reset or how cell_test is run but this will increment i each time the function is run.
function cell_test()
try
// Increment i
var props = PropertiesService.getScriptProperties();
var i = props.getProperty("Test");
if( i === null )
i = 8;
else
i++;
props.setProperty("Test", i);
// Put your code here
var ss = SpreadsheetApp.getActiveSpreadsheet ();
var source = ss.getRange ("A!C1");
var destSheet = ss.getSheetByName("B");
var destRange = destSheet.getRange(i,2);
source.copyTo (destRange, contentsOnly: true);
catch(err)
Logger.log(err);
add a comment |
Storing and Incrementing a variable in the Properties Service
Try this:
function initI()
PropertiesService.getScriptProperties().setProperty('i',8);
return Number(PropertiesService.getScriptProperties().getProperty('i'));
function incrI()
var ps=PropertiesService.getScriptProperties();
var i=Number(ps.getProperty('i'));
ps.setProperty('i',i+1);
function getI()
var ps=PropertiesService.getScriptProperties();
var pObj=ps.getProperties();
if(pObj.hasOwnProperty('i'))
var i=Number(ps.getProperty('i'));
return i;
else
return initI();
function cell_test()
var i=getI();
var ss = SpreadsheetApp.getActiveSpreadsheet ();
var source = ss.getRange ("A!C1");
var destSheet = ss.getSheetByName("B");
var destRange = destSheet.getRange(i,2);
source.copyTo (destRange, contentsOnly: true);
incrI();
- PropertiesService
This is handy because all you have to do is add var
i=getI();at the beginning of any test function and atincrI();at the end of your test function and the rest is taken care of. If your I is not defined in the property service getI() will take care of that for you. If you wish to start all over you can just run initI() and that will set it to the default value which is currently 8. If you wish to change the default value then just change the 8 in initI() and your done. You can completely delete the PropertiesService value for in in the Files/Project Properties/Script Properties dialog.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55339720%2fhow-to-increase-i-to-next-call%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
You can make i a function parameter and call the function from a for loop:
function main()
var startRow = 8;
var endRow = 10;
for(var i=startRow; i<=endRow; i++)
cell_test(i);
function cell_test(i)
var ss = SpreadsheetApp.getActiveSpreadsheet ();
var source = ss.getRange ("A!C1");
var destSheet = ss.getSheetByName("B");
var destRange = destSheet.getRange(i,2);
source.copyTo (destRange, contentsOnly: true);
This will copy the content of cell A!C1 to cell B!B8, B!B9 and B!B10.
add a comment |
You can make i a function parameter and call the function from a for loop:
function main()
var startRow = 8;
var endRow = 10;
for(var i=startRow; i<=endRow; i++)
cell_test(i);
function cell_test(i)
var ss = SpreadsheetApp.getActiveSpreadsheet ();
var source = ss.getRange ("A!C1");
var destSheet = ss.getSheetByName("B");
var destRange = destSheet.getRange(i,2);
source.copyTo (destRange, contentsOnly: true);
This will copy the content of cell A!C1 to cell B!B8, B!B9 and B!B10.
add a comment |
You can make i a function parameter and call the function from a for loop:
function main()
var startRow = 8;
var endRow = 10;
for(var i=startRow; i<=endRow; i++)
cell_test(i);
function cell_test(i)
var ss = SpreadsheetApp.getActiveSpreadsheet ();
var source = ss.getRange ("A!C1");
var destSheet = ss.getSheetByName("B");
var destRange = destSheet.getRange(i,2);
source.copyTo (destRange, contentsOnly: true);
This will copy the content of cell A!C1 to cell B!B8, B!B9 and B!B10.
You can make i a function parameter and call the function from a for loop:
function main()
var startRow = 8;
var endRow = 10;
for(var i=startRow; i<=endRow; i++)
cell_test(i);
function cell_test(i)
var ss = SpreadsheetApp.getActiveSpreadsheet ();
var source = ss.getRange ("A!C1");
var destSheet = ss.getSheetByName("B");
var destRange = destSheet.getRange(i,2);
source.copyTo (destRange, contentsOnly: true);
This will copy the content of cell A!C1 to cell B!B8, B!B9 and B!B10.
answered Mar 25 at 18:06
glhrglhr
3,3131 gold badge9 silver badges21 bronze badges
3,3131 gold badge9 silver badges21 bronze badges
add a comment |
add a comment |
I don't know if i needs to be reset or how cell_test is run but this will increment i each time the function is run.
function cell_test()
try
// Increment i
var props = PropertiesService.getScriptProperties();
var i = props.getProperty("Test");
if( i === null )
i = 8;
else
i++;
props.setProperty("Test", i);
// Put your code here
var ss = SpreadsheetApp.getActiveSpreadsheet ();
var source = ss.getRange ("A!C1");
var destSheet = ss.getSheetByName("B");
var destRange = destSheet.getRange(i,2);
source.copyTo (destRange, contentsOnly: true);
catch(err)
Logger.log(err);
add a comment |
I don't know if i needs to be reset or how cell_test is run but this will increment i each time the function is run.
function cell_test()
try
// Increment i
var props = PropertiesService.getScriptProperties();
var i = props.getProperty("Test");
if( i === null )
i = 8;
else
i++;
props.setProperty("Test", i);
// Put your code here
var ss = SpreadsheetApp.getActiveSpreadsheet ();
var source = ss.getRange ("A!C1");
var destSheet = ss.getSheetByName("B");
var destRange = destSheet.getRange(i,2);
source.copyTo (destRange, contentsOnly: true);
catch(err)
Logger.log(err);
add a comment |
I don't know if i needs to be reset or how cell_test is run but this will increment i each time the function is run.
function cell_test()
try
// Increment i
var props = PropertiesService.getScriptProperties();
var i = props.getProperty("Test");
if( i === null )
i = 8;
else
i++;
props.setProperty("Test", i);
// Put your code here
var ss = SpreadsheetApp.getActiveSpreadsheet ();
var source = ss.getRange ("A!C1");
var destSheet = ss.getSheetByName("B");
var destRange = destSheet.getRange(i,2);
source.copyTo (destRange, contentsOnly: true);
catch(err)
Logger.log(err);
I don't know if i needs to be reset or how cell_test is run but this will increment i each time the function is run.
function cell_test()
try
// Increment i
var props = PropertiesService.getScriptProperties();
var i = props.getProperty("Test");
if( i === null )
i = 8;
else
i++;
props.setProperty("Test", i);
// Put your code here
var ss = SpreadsheetApp.getActiveSpreadsheet ();
var source = ss.getRange ("A!C1");
var destSheet = ss.getSheetByName("B");
var destRange = destSheet.getRange(i,2);
source.copyTo (destRange, contentsOnly: true);
catch(err)
Logger.log(err);
answered Mar 25 at 18:07
TheWizEdTheWizEd
7101 gold badge5 silver badges9 bronze badges
7101 gold badge5 silver badges9 bronze badges
add a comment |
add a comment |
Storing and Incrementing a variable in the Properties Service
Try this:
function initI()
PropertiesService.getScriptProperties().setProperty('i',8);
return Number(PropertiesService.getScriptProperties().getProperty('i'));
function incrI()
var ps=PropertiesService.getScriptProperties();
var i=Number(ps.getProperty('i'));
ps.setProperty('i',i+1);
function getI()
var ps=PropertiesService.getScriptProperties();
var pObj=ps.getProperties();
if(pObj.hasOwnProperty('i'))
var i=Number(ps.getProperty('i'));
return i;
else
return initI();
function cell_test()
var i=getI();
var ss = SpreadsheetApp.getActiveSpreadsheet ();
var source = ss.getRange ("A!C1");
var destSheet = ss.getSheetByName("B");
var destRange = destSheet.getRange(i,2);
source.copyTo (destRange, contentsOnly: true);
incrI();
- PropertiesService
This is handy because all you have to do is add var
i=getI();at the beginning of any test function and atincrI();at the end of your test function and the rest is taken care of. If your I is not defined in the property service getI() will take care of that for you. If you wish to start all over you can just run initI() and that will set it to the default value which is currently 8. If you wish to change the default value then just change the 8 in initI() and your done. You can completely delete the PropertiesService value for in in the Files/Project Properties/Script Properties dialog.
add a comment |
Storing and Incrementing a variable in the Properties Service
Try this:
function initI()
PropertiesService.getScriptProperties().setProperty('i',8);
return Number(PropertiesService.getScriptProperties().getProperty('i'));
function incrI()
var ps=PropertiesService.getScriptProperties();
var i=Number(ps.getProperty('i'));
ps.setProperty('i',i+1);
function getI()
var ps=PropertiesService.getScriptProperties();
var pObj=ps.getProperties();
if(pObj.hasOwnProperty('i'))
var i=Number(ps.getProperty('i'));
return i;
else
return initI();
function cell_test()
var i=getI();
var ss = SpreadsheetApp.getActiveSpreadsheet ();
var source = ss.getRange ("A!C1");
var destSheet = ss.getSheetByName("B");
var destRange = destSheet.getRange(i,2);
source.copyTo (destRange, contentsOnly: true);
incrI();
- PropertiesService
This is handy because all you have to do is add var
i=getI();at the beginning of any test function and atincrI();at the end of your test function and the rest is taken care of. If your I is not defined in the property service getI() will take care of that for you. If you wish to start all over you can just run initI() and that will set it to the default value which is currently 8. If you wish to change the default value then just change the 8 in initI() and your done. You can completely delete the PropertiesService value for in in the Files/Project Properties/Script Properties dialog.
add a comment |
Storing and Incrementing a variable in the Properties Service
Try this:
function initI()
PropertiesService.getScriptProperties().setProperty('i',8);
return Number(PropertiesService.getScriptProperties().getProperty('i'));
function incrI()
var ps=PropertiesService.getScriptProperties();
var i=Number(ps.getProperty('i'));
ps.setProperty('i',i+1);
function getI()
var ps=PropertiesService.getScriptProperties();
var pObj=ps.getProperties();
if(pObj.hasOwnProperty('i'))
var i=Number(ps.getProperty('i'));
return i;
else
return initI();
function cell_test()
var i=getI();
var ss = SpreadsheetApp.getActiveSpreadsheet ();
var source = ss.getRange ("A!C1");
var destSheet = ss.getSheetByName("B");
var destRange = destSheet.getRange(i,2);
source.copyTo (destRange, contentsOnly: true);
incrI();
- PropertiesService
This is handy because all you have to do is add var
i=getI();at the beginning of any test function and atincrI();at the end of your test function and the rest is taken care of. If your I is not defined in the property service getI() will take care of that for you. If you wish to start all over you can just run initI() and that will set it to the default value which is currently 8. If you wish to change the default value then just change the 8 in initI() and your done. You can completely delete the PropertiesService value for in in the Files/Project Properties/Script Properties dialog.
Storing and Incrementing a variable in the Properties Service
Try this:
function initI()
PropertiesService.getScriptProperties().setProperty('i',8);
return Number(PropertiesService.getScriptProperties().getProperty('i'));
function incrI()
var ps=PropertiesService.getScriptProperties();
var i=Number(ps.getProperty('i'));
ps.setProperty('i',i+1);
function getI()
var ps=PropertiesService.getScriptProperties();
var pObj=ps.getProperties();
if(pObj.hasOwnProperty('i'))
var i=Number(ps.getProperty('i'));
return i;
else
return initI();
function cell_test()
var i=getI();
var ss = SpreadsheetApp.getActiveSpreadsheet ();
var source = ss.getRange ("A!C1");
var destSheet = ss.getSheetByName("B");
var destRange = destSheet.getRange(i,2);
source.copyTo (destRange, contentsOnly: true);
incrI();
- PropertiesService
This is handy because all you have to do is add var
i=getI();at the beginning of any test function and atincrI();at the end of your test function and the rest is taken care of. If your I is not defined in the property service getI() will take care of that for you. If you wish to start all over you can just run initI() and that will set it to the default value which is currently 8. If you wish to change the default value then just change the 8 in initI() and your done. You can completely delete the PropertiesService value for in in the Files/Project Properties/Script Properties dialog.
edited Mar 25 at 21:13
answered Mar 25 at 18:11
CooperCooper
10.5k2 gold badges9 silver badges31 bronze badges
10.5k2 gold badges9 silver badges31 bronze badges
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55339720%2fhow-to-increase-i-to-next-call%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
What is "i"? Always 8 when you open the spreadsheet? The first empty row of B? And how is cell_test run, from menu, custom formula, onEdit?
– TheWizEd
Mar 25 at 14:22
the target cell is B sheet (8.2) which i want to paste. so i give i value to 8.Then i will paste value to B sheet (9.2).
– SY Moon
Mar 25 at 14:35
You haven't answered my questions.
– TheWizEd
Mar 25 at 17:05