How use the ImportRange Refresh script?











up vote
0
down vote

favorite












I do not know Script.



I have found a way to reference an external sheet faster than ImportRange, but I do not know how to use this script.



Can I get an example that uses this script?



I need help.





 // this function creates a menu item on the top that you can click the refresh the data, you could also use triggers to refresh
function onOpen() {
var spreadsheet = SpreadsheetApp.getActive();
var menuItems = [{name: 'Refresh', functionName: 'getData'}];
spreadsheet.addMenu('Menu', menuItems);
}
function getData() {
var key = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Sheet1").getRange("A1").getValue(); // you would place the spreadsheet key in A1, alternatively you can enter the key directly here rather than referencing
var sourceSs = SpreadsheetApp.openById(key);
var sourceSheet = sourceSs.getSheetByName("Sheet1");
var sourceRange = sourceSheet.getRange("A1:C");
var sourceValues = sourceRange.getValues();
var destSs = SpreadsheetApp.getActiveSpreadsheet();
var destSheet = destSs.getSheetByName("Sheet1");
var desRange = destSheet.getRange("A1:C")
destRange.setValues(sourceValues);
}




Sorry. I do not seem to be properly delivered because I am not fluent in English.
I had to come to StackOverFlow because there were very few GAS users in Korea.



Initially, // my level knows how to use most of the functionality of a spreadsheet, except scripts.



I've had over 100,000 rows in my experience, and after splitting the sheet, I used the IMPORTRANGE function to collect the results in a single spreadsheet.



However, this spreadsheet had a huge amount of real-time updates, so we had to find a way to speed it up.



After that, I found the source code above and saved it. However, an error occurred at destRange.setValues ​​(sourceValues); at the bottom.



I tried to modify the source code, but the result is the same.



I think you can see how to use the source code in the examples that are actually applied.










share|improve this question









New contributor




김지민 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • What have you tried so far?
    – TheMaster
    yesterday















up vote
0
down vote

favorite












I do not know Script.



I have found a way to reference an external sheet faster than ImportRange, but I do not know how to use this script.



Can I get an example that uses this script?



I need help.





 // this function creates a menu item on the top that you can click the refresh the data, you could also use triggers to refresh
function onOpen() {
var spreadsheet = SpreadsheetApp.getActive();
var menuItems = [{name: 'Refresh', functionName: 'getData'}];
spreadsheet.addMenu('Menu', menuItems);
}
function getData() {
var key = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Sheet1").getRange("A1").getValue(); // you would place the spreadsheet key in A1, alternatively you can enter the key directly here rather than referencing
var sourceSs = SpreadsheetApp.openById(key);
var sourceSheet = sourceSs.getSheetByName("Sheet1");
var sourceRange = sourceSheet.getRange("A1:C");
var sourceValues = sourceRange.getValues();
var destSs = SpreadsheetApp.getActiveSpreadsheet();
var destSheet = destSs.getSheetByName("Sheet1");
var desRange = destSheet.getRange("A1:C")
destRange.setValues(sourceValues);
}




Sorry. I do not seem to be properly delivered because I am not fluent in English.
I had to come to StackOverFlow because there were very few GAS users in Korea.



Initially, // my level knows how to use most of the functionality of a spreadsheet, except scripts.



I've had over 100,000 rows in my experience, and after splitting the sheet, I used the IMPORTRANGE function to collect the results in a single spreadsheet.



However, this spreadsheet had a huge amount of real-time updates, so we had to find a way to speed it up.



After that, I found the source code above and saved it. However, an error occurred at destRange.setValues ​​(sourceValues); at the bottom.



I tried to modify the source code, but the result is the same.



I think you can see how to use the source code in the examples that are actually applied.










share|improve this question









New contributor




김지민 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • What have you tried so far?
    – TheMaster
    yesterday













up vote
0
down vote

favorite









up vote
0
down vote

favorite











I do not know Script.



I have found a way to reference an external sheet faster than ImportRange, but I do not know how to use this script.



Can I get an example that uses this script?



I need help.





 // this function creates a menu item on the top that you can click the refresh the data, you could also use triggers to refresh
function onOpen() {
var spreadsheet = SpreadsheetApp.getActive();
var menuItems = [{name: 'Refresh', functionName: 'getData'}];
spreadsheet.addMenu('Menu', menuItems);
}
function getData() {
var key = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Sheet1").getRange("A1").getValue(); // you would place the spreadsheet key in A1, alternatively you can enter the key directly here rather than referencing
var sourceSs = SpreadsheetApp.openById(key);
var sourceSheet = sourceSs.getSheetByName("Sheet1");
var sourceRange = sourceSheet.getRange("A1:C");
var sourceValues = sourceRange.getValues();
var destSs = SpreadsheetApp.getActiveSpreadsheet();
var destSheet = destSs.getSheetByName("Sheet1");
var desRange = destSheet.getRange("A1:C")
destRange.setValues(sourceValues);
}




Sorry. I do not seem to be properly delivered because I am not fluent in English.
I had to come to StackOverFlow because there were very few GAS users in Korea.



Initially, // my level knows how to use most of the functionality of a spreadsheet, except scripts.



I've had over 100,000 rows in my experience, and after splitting the sheet, I used the IMPORTRANGE function to collect the results in a single spreadsheet.



However, this spreadsheet had a huge amount of real-time updates, so we had to find a way to speed it up.



After that, I found the source code above and saved it. However, an error occurred at destRange.setValues ​​(sourceValues); at the bottom.



I tried to modify the source code, but the result is the same.



I think you can see how to use the source code in the examples that are actually applied.










share|improve this question









New contributor




김지민 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











I do not know Script.



I have found a way to reference an external sheet faster than ImportRange, but I do not know how to use this script.



Can I get an example that uses this script?



I need help.





 // this function creates a menu item on the top that you can click the refresh the data, you could also use triggers to refresh
function onOpen() {
var spreadsheet = SpreadsheetApp.getActive();
var menuItems = [{name: 'Refresh', functionName: 'getData'}];
spreadsheet.addMenu('Menu', menuItems);
}
function getData() {
var key = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Sheet1").getRange("A1").getValue(); // you would place the spreadsheet key in A1, alternatively you can enter the key directly here rather than referencing
var sourceSs = SpreadsheetApp.openById(key);
var sourceSheet = sourceSs.getSheetByName("Sheet1");
var sourceRange = sourceSheet.getRange("A1:C");
var sourceValues = sourceRange.getValues();
var destSs = SpreadsheetApp.getActiveSpreadsheet();
var destSheet = destSs.getSheetByName("Sheet1");
var desRange = destSheet.getRange("A1:C")
destRange.setValues(sourceValues);
}




Sorry. I do not seem to be properly delivered because I am not fluent in English.
I had to come to StackOverFlow because there were very few GAS users in Korea.



Initially, // my level knows how to use most of the functionality of a spreadsheet, except scripts.



I've had over 100,000 rows in my experience, and after splitting the sheet, I used the IMPORTRANGE function to collect the results in a single spreadsheet.



However, this spreadsheet had a huge amount of real-time updates, so we had to find a way to speed it up.



After that, I found the source code above and saved it. However, an error occurred at destRange.setValues ​​(sourceValues); at the bottom.



I tried to modify the source code, but the result is the same.



I think you can see how to use the source code in the examples that are actually applied.







google-apps-script






share|improve this question









New contributor




김지민 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




김지민 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited 9 hours ago





















New contributor




김지민 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked yesterday









김지민

11




11




New contributor




김지민 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





김지민 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






김지민 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












  • What have you tried so far?
    – TheMaster
    yesterday


















  • What have you tried so far?
    – TheMaster
    yesterday
















What have you tried so far?
– TheMaster
yesterday




What have you tried so far?
– TheMaster
yesterday












1 Answer
1






active

oldest

votes

















up vote
0
down vote













You need to do a few things, not hard but specific:
1) Get the keys to the source and target spreadsheets. These are the long gobbledy-gook strings inside the URL that opens the sheet. If you see a URL like this: https://docs.google.com/spreadsheets/d/1fPvp5o2-xeH04STyeaoC_iJTy1JRGQZki3_j1l39wMQ/edit#gid=0, the ID of the sheet is the part after spreadsheets/d/ and before /edit. Place those keys in the code for sourceSs and destSs.



Open the target sheet. From the menu choose Tools -> Script editor. Assuming you've done nothing so far, you'll get a default "MyFunction()". Clear that text and copy/paste your code above, including the keys. Save the code. Close the code window, close the spreadsheet and reopen the target spreadsheet.



To actually update the values on the target spreadsheet, the user will be required to select the menu item "Refresh". The first time, the user will be required to authorize permissions to the script.



Give this a try. It's quite straightforward, once you know how.






share|improve this answer








New contributor




Michael Ellis is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.


















  • File is not available by your link
    – Boris Sokolov
    yesterday










  • Boris, I only used that as a sample - I modified it intentionally to avoid giving away a real file from My Drive.
    – Michael Ellis
    yesterday










  • Ah... I thought it was a part of your sample :)
    – Boris Sokolov
    yesterday











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',
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
});


}
});






김지민 is a new contributor. Be nice, and check out our Code of Conduct.










 

draft saved


draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53183751%2fhow-use-the-importrange-refresh-script%23new-answer', 'question_page');
}
);

Post as a guest
































1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
0
down vote













You need to do a few things, not hard but specific:
1) Get the keys to the source and target spreadsheets. These are the long gobbledy-gook strings inside the URL that opens the sheet. If you see a URL like this: https://docs.google.com/spreadsheets/d/1fPvp5o2-xeH04STyeaoC_iJTy1JRGQZki3_j1l39wMQ/edit#gid=0, the ID of the sheet is the part after spreadsheets/d/ and before /edit. Place those keys in the code for sourceSs and destSs.



Open the target sheet. From the menu choose Tools -> Script editor. Assuming you've done nothing so far, you'll get a default "MyFunction()". Clear that text and copy/paste your code above, including the keys. Save the code. Close the code window, close the spreadsheet and reopen the target spreadsheet.



To actually update the values on the target spreadsheet, the user will be required to select the menu item "Refresh". The first time, the user will be required to authorize permissions to the script.



Give this a try. It's quite straightforward, once you know how.






share|improve this answer








New contributor




Michael Ellis is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.


















  • File is not available by your link
    – Boris Sokolov
    yesterday










  • Boris, I only used that as a sample - I modified it intentionally to avoid giving away a real file from My Drive.
    – Michael Ellis
    yesterday










  • Ah... I thought it was a part of your sample :)
    – Boris Sokolov
    yesterday















up vote
0
down vote













You need to do a few things, not hard but specific:
1) Get the keys to the source and target spreadsheets. These are the long gobbledy-gook strings inside the URL that opens the sheet. If you see a URL like this: https://docs.google.com/spreadsheets/d/1fPvp5o2-xeH04STyeaoC_iJTy1JRGQZki3_j1l39wMQ/edit#gid=0, the ID of the sheet is the part after spreadsheets/d/ and before /edit. Place those keys in the code for sourceSs and destSs.



Open the target sheet. From the menu choose Tools -> Script editor. Assuming you've done nothing so far, you'll get a default "MyFunction()". Clear that text and copy/paste your code above, including the keys. Save the code. Close the code window, close the spreadsheet and reopen the target spreadsheet.



To actually update the values on the target spreadsheet, the user will be required to select the menu item "Refresh". The first time, the user will be required to authorize permissions to the script.



Give this a try. It's quite straightforward, once you know how.






share|improve this answer








New contributor




Michael Ellis is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.


















  • File is not available by your link
    – Boris Sokolov
    yesterday










  • Boris, I only used that as a sample - I modified it intentionally to avoid giving away a real file from My Drive.
    – Michael Ellis
    yesterday










  • Ah... I thought it was a part of your sample :)
    – Boris Sokolov
    yesterday













up vote
0
down vote










up vote
0
down vote









You need to do a few things, not hard but specific:
1) Get the keys to the source and target spreadsheets. These are the long gobbledy-gook strings inside the URL that opens the sheet. If you see a URL like this: https://docs.google.com/spreadsheets/d/1fPvp5o2-xeH04STyeaoC_iJTy1JRGQZki3_j1l39wMQ/edit#gid=0, the ID of the sheet is the part after spreadsheets/d/ and before /edit. Place those keys in the code for sourceSs and destSs.



Open the target sheet. From the menu choose Tools -> Script editor. Assuming you've done nothing so far, you'll get a default "MyFunction()". Clear that text and copy/paste your code above, including the keys. Save the code. Close the code window, close the spreadsheet and reopen the target spreadsheet.



To actually update the values on the target spreadsheet, the user will be required to select the menu item "Refresh". The first time, the user will be required to authorize permissions to the script.



Give this a try. It's quite straightforward, once you know how.






share|improve this answer








New contributor




Michael Ellis is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









You need to do a few things, not hard but specific:
1) Get the keys to the source and target spreadsheets. These are the long gobbledy-gook strings inside the URL that opens the sheet. If you see a URL like this: https://docs.google.com/spreadsheets/d/1fPvp5o2-xeH04STyeaoC_iJTy1JRGQZki3_j1l39wMQ/edit#gid=0, the ID of the sheet is the part after spreadsheets/d/ and before /edit. Place those keys in the code for sourceSs and destSs.



Open the target sheet. From the menu choose Tools -> Script editor. Assuming you've done nothing so far, you'll get a default "MyFunction()". Clear that text and copy/paste your code above, including the keys. Save the code. Close the code window, close the spreadsheet and reopen the target spreadsheet.



To actually update the values on the target spreadsheet, the user will be required to select the menu item "Refresh". The first time, the user will be required to authorize permissions to the script.



Give this a try. It's quite straightforward, once you know how.







share|improve this answer








New contributor




Michael Ellis is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this answer



share|improve this answer






New contributor




Michael Ellis is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









answered yesterday









Michael Ellis

112




112




New contributor




Michael Ellis is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Michael Ellis is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Michael Ellis is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












  • File is not available by your link
    – Boris Sokolov
    yesterday










  • Boris, I only used that as a sample - I modified it intentionally to avoid giving away a real file from My Drive.
    – Michael Ellis
    yesterday










  • Ah... I thought it was a part of your sample :)
    – Boris Sokolov
    yesterday


















  • File is not available by your link
    – Boris Sokolov
    yesterday










  • Boris, I only used that as a sample - I modified it intentionally to avoid giving away a real file from My Drive.
    – Michael Ellis
    yesterday










  • Ah... I thought it was a part of your sample :)
    – Boris Sokolov
    yesterday
















File is not available by your link
– Boris Sokolov
yesterday




File is not available by your link
– Boris Sokolov
yesterday












Boris, I only used that as a sample - I modified it intentionally to avoid giving away a real file from My Drive.
– Michael Ellis
yesterday




Boris, I only used that as a sample - I modified it intentionally to avoid giving away a real file from My Drive.
– Michael Ellis
yesterday












Ah... I thought it was a part of your sample :)
– Boris Sokolov
yesterday




Ah... I thought it was a part of your sample :)
– Boris Sokolov
yesterday










김지민 is a new contributor. Be nice, and check out our Code of Conduct.










 

draft saved


draft discarded


















김지민 is a new contributor. Be nice, and check out our Code of Conduct.













김지민 is a new contributor. Be nice, and check out our Code of Conduct.












김지민 is a new contributor. Be nice, and check out our Code of Conduct.















 


draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53183751%2fhow-use-the-importrange-refresh-script%23new-answer', 'question_page');
}
);

Post as a guest




















































































Popular posts from this blog

横浜市

Rostock

Europa