Updating old formatted spreadsheets using a reformatted spreadsheet that takes the old values and duplicates...
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
CODE IS DONE thx @TheMaster ✔
I'm an absolute novice in the google drive sdk, excuse me.
I'm trying to write a script, which allows many sheets that are identical to updated. Through a Source spreadsheet (with new formatting). Problem is that in the old sheets, values are in there, which must be in the new sheet "Source spreadsheet" (with new formatting) in there. And then again and again with an old sheet reiterate.
Procedure in my mind for the script:
go to folder where many sheets are✔
open the first sheet and then always the next✔
take the data from area (A1:A2;C1:C2)✔
take the name of the sheets✔
Copy them into the data in the source spreadsheet in the same place✔
Make a copy of the source spreadsheet✔
Name the source spreadsheet as the old sheet✔
rename it and put it in another folder✔
I will help, where I can.
current code:
function UPDATE() {
//LEGEND: o=Old, ss=SpreadSheet, sss=SourceSreadSheet, s=Sheet, n=Name//
//---TAKE ALL OLD SPREADSHEEDS FROM FOLDER ---//
//replace it with Folder ID where the old spreadsheets are in
var folder=DriveApp.getFolderById('Folder ID')
//takes all files in the folder and sets the variable file
var files=folder.getFiles();
while (files.hasNext())
{
var file = files.next();
//---TAKE DATA---//
//replace with source ID
var o_ss=SpreadsheetApp.open(file);
//replace with source Sheet tab name 1 to as much as you want
var o_s_n1=o_ss.getSheetByName('tab name1');
var o_s_n2=o_ss.getSheetByName('tab name2'); //optional
//assign one ore more ranges you want to copy
var o_range1=o_s_n1.getRange('A1:A2');
var o_range2=o_s_n1.getRange('C1:C2'); //optional
//Copy the values
var o_data1=o_range1.getValues();
var o_data2=o_range2.getValues(); //optional
//---COPY DATA---//
//replace with destination ID
var sss_ss=SpreadsheetApp.openById('destination ID');
//replace with destination Sheet tab name
var sss_s=sss_ss.getSheetByName('tab name1');
//Area where to copy in the new sheet
sss_s.getRange('A1:A2').setValues(o_data1);
sss_s.getRange('C1:C2').setValues(o_data2); //optional
//closes the code until here first
SpreadsheetApp.flush();
//---DUPLIKATE SOURCE SHEET AND RENAME IT AND PUT IT IN THE DESTINATION FOLDER---//
//gets the sheet name from the old sheet
var o_ss_n=o_ss.getName();
//replace with destination Folder ID
var folder=DriveApp.getFolderById('Folder ID')
//Copy the destination sheet and name it like the old sheet
DriveApp.getFileById('destination ID').makeCopy(o_ss_n,folder);
}
}
google-apps-script google-sheets google-drive-sdk
|
show 2 more comments
CODE IS DONE thx @TheMaster ✔
I'm an absolute novice in the google drive sdk, excuse me.
I'm trying to write a script, which allows many sheets that are identical to updated. Through a Source spreadsheet (with new formatting). Problem is that in the old sheets, values are in there, which must be in the new sheet "Source spreadsheet" (with new formatting) in there. And then again and again with an old sheet reiterate.
Procedure in my mind for the script:
go to folder where many sheets are✔
open the first sheet and then always the next✔
take the data from area (A1:A2;C1:C2)✔
take the name of the sheets✔
Copy them into the data in the source spreadsheet in the same place✔
Make a copy of the source spreadsheet✔
Name the source spreadsheet as the old sheet✔
rename it and put it in another folder✔
I will help, where I can.
current code:
function UPDATE() {
//LEGEND: o=Old, ss=SpreadSheet, sss=SourceSreadSheet, s=Sheet, n=Name//
//---TAKE ALL OLD SPREADSHEEDS FROM FOLDER ---//
//replace it with Folder ID where the old spreadsheets are in
var folder=DriveApp.getFolderById('Folder ID')
//takes all files in the folder and sets the variable file
var files=folder.getFiles();
while (files.hasNext())
{
var file = files.next();
//---TAKE DATA---//
//replace with source ID
var o_ss=SpreadsheetApp.open(file);
//replace with source Sheet tab name 1 to as much as you want
var o_s_n1=o_ss.getSheetByName('tab name1');
var o_s_n2=o_ss.getSheetByName('tab name2'); //optional
//assign one ore more ranges you want to copy
var o_range1=o_s_n1.getRange('A1:A2');
var o_range2=o_s_n1.getRange('C1:C2'); //optional
//Copy the values
var o_data1=o_range1.getValues();
var o_data2=o_range2.getValues(); //optional
//---COPY DATA---//
//replace with destination ID
var sss_ss=SpreadsheetApp.openById('destination ID');
//replace with destination Sheet tab name
var sss_s=sss_ss.getSheetByName('tab name1');
//Area where to copy in the new sheet
sss_s.getRange('A1:A2').setValues(o_data1);
sss_s.getRange('C1:C2').setValues(o_data2); //optional
//closes the code until here first
SpreadsheetApp.flush();
//---DUPLIKATE SOURCE SHEET AND RENAME IT AND PUT IT IN THE DESTINATION FOLDER---//
//gets the sheet name from the old sheet
var o_ss_n=o_ss.getName();
//replace with destination Folder ID
var folder=DriveApp.getFolderById('Folder ID')
//Copy the destination sheet and name it like the old sheet
DriveApp.getFileById('destination ID').makeCopy(o_ss_n,folder);
}
}
google-apps-script google-sheets google-drive-sdk
Try what you dreamt of and if you run into a specific problem, provide Minimal, Complete, and Verifiable example
– TheMaster
Nov 24 '18 at 21:41
@TheMaster I have updated my code, I do not get the repeat function, do you still have an idea? Would it be nice to work here with flush ()?
– KillBill_158
Nov 28 '18 at 16:49
You'll get the folder first > then execute this function you wrote for all the files in the folder inside the while loop. See the first example here
– TheMaster
Nov 28 '18 at 19:30
@TheMaster Now he takes all the files in a folder and copies them but he does not take the areas from the spreadsheets. what's wrong here? do you have to do that with an array?
– KillBill_158
Dec 5 '18 at 18:52
@TheMaster The code works, but it does not take the Ranges from the old tables and copies them to the new spreadsheet. where exactly is the error?
– KillBill_158
Dec 5 '18 at 20:54
|
show 2 more comments
CODE IS DONE thx @TheMaster ✔
I'm an absolute novice in the google drive sdk, excuse me.
I'm trying to write a script, which allows many sheets that are identical to updated. Through a Source spreadsheet (with new formatting). Problem is that in the old sheets, values are in there, which must be in the new sheet "Source spreadsheet" (with new formatting) in there. And then again and again with an old sheet reiterate.
Procedure in my mind for the script:
go to folder where many sheets are✔
open the first sheet and then always the next✔
take the data from area (A1:A2;C1:C2)✔
take the name of the sheets✔
Copy them into the data in the source spreadsheet in the same place✔
Make a copy of the source spreadsheet✔
Name the source spreadsheet as the old sheet✔
rename it and put it in another folder✔
I will help, where I can.
current code:
function UPDATE() {
//LEGEND: o=Old, ss=SpreadSheet, sss=SourceSreadSheet, s=Sheet, n=Name//
//---TAKE ALL OLD SPREADSHEEDS FROM FOLDER ---//
//replace it with Folder ID where the old spreadsheets are in
var folder=DriveApp.getFolderById('Folder ID')
//takes all files in the folder and sets the variable file
var files=folder.getFiles();
while (files.hasNext())
{
var file = files.next();
//---TAKE DATA---//
//replace with source ID
var o_ss=SpreadsheetApp.open(file);
//replace with source Sheet tab name 1 to as much as you want
var o_s_n1=o_ss.getSheetByName('tab name1');
var o_s_n2=o_ss.getSheetByName('tab name2'); //optional
//assign one ore more ranges you want to copy
var o_range1=o_s_n1.getRange('A1:A2');
var o_range2=o_s_n1.getRange('C1:C2'); //optional
//Copy the values
var o_data1=o_range1.getValues();
var o_data2=o_range2.getValues(); //optional
//---COPY DATA---//
//replace with destination ID
var sss_ss=SpreadsheetApp.openById('destination ID');
//replace with destination Sheet tab name
var sss_s=sss_ss.getSheetByName('tab name1');
//Area where to copy in the new sheet
sss_s.getRange('A1:A2').setValues(o_data1);
sss_s.getRange('C1:C2').setValues(o_data2); //optional
//closes the code until here first
SpreadsheetApp.flush();
//---DUPLIKATE SOURCE SHEET AND RENAME IT AND PUT IT IN THE DESTINATION FOLDER---//
//gets the sheet name from the old sheet
var o_ss_n=o_ss.getName();
//replace with destination Folder ID
var folder=DriveApp.getFolderById('Folder ID')
//Copy the destination sheet and name it like the old sheet
DriveApp.getFileById('destination ID').makeCopy(o_ss_n,folder);
}
}
google-apps-script google-sheets google-drive-sdk
CODE IS DONE thx @TheMaster ✔
I'm an absolute novice in the google drive sdk, excuse me.
I'm trying to write a script, which allows many sheets that are identical to updated. Through a Source spreadsheet (with new formatting). Problem is that in the old sheets, values are in there, which must be in the new sheet "Source spreadsheet" (with new formatting) in there. And then again and again with an old sheet reiterate.
Procedure in my mind for the script:
go to folder where many sheets are✔
open the first sheet and then always the next✔
take the data from area (A1:A2;C1:C2)✔
take the name of the sheets✔
Copy them into the data in the source spreadsheet in the same place✔
Make a copy of the source spreadsheet✔
Name the source spreadsheet as the old sheet✔
rename it and put it in another folder✔
I will help, where I can.
current code:
function UPDATE() {
//LEGEND: o=Old, ss=SpreadSheet, sss=SourceSreadSheet, s=Sheet, n=Name//
//---TAKE ALL OLD SPREADSHEEDS FROM FOLDER ---//
//replace it with Folder ID where the old spreadsheets are in
var folder=DriveApp.getFolderById('Folder ID')
//takes all files in the folder and sets the variable file
var files=folder.getFiles();
while (files.hasNext())
{
var file = files.next();
//---TAKE DATA---//
//replace with source ID
var o_ss=SpreadsheetApp.open(file);
//replace with source Sheet tab name 1 to as much as you want
var o_s_n1=o_ss.getSheetByName('tab name1');
var o_s_n2=o_ss.getSheetByName('tab name2'); //optional
//assign one ore more ranges you want to copy
var o_range1=o_s_n1.getRange('A1:A2');
var o_range2=o_s_n1.getRange('C1:C2'); //optional
//Copy the values
var o_data1=o_range1.getValues();
var o_data2=o_range2.getValues(); //optional
//---COPY DATA---//
//replace with destination ID
var sss_ss=SpreadsheetApp.openById('destination ID');
//replace with destination Sheet tab name
var sss_s=sss_ss.getSheetByName('tab name1');
//Area where to copy in the new sheet
sss_s.getRange('A1:A2').setValues(o_data1);
sss_s.getRange('C1:C2').setValues(o_data2); //optional
//closes the code until here first
SpreadsheetApp.flush();
//---DUPLIKATE SOURCE SHEET AND RENAME IT AND PUT IT IN THE DESTINATION FOLDER---//
//gets the sheet name from the old sheet
var o_ss_n=o_ss.getName();
//replace with destination Folder ID
var folder=DriveApp.getFolderById('Folder ID')
//Copy the destination sheet and name it like the old sheet
DriveApp.getFileById('destination ID').makeCopy(o_ss_n,folder);
}
}
function UPDATE() {
//LEGEND: o=Old, ss=SpreadSheet, sss=SourceSreadSheet, s=Sheet, n=Name//
//---TAKE ALL OLD SPREADSHEEDS FROM FOLDER ---//
//replace it with Folder ID where the old spreadsheets are in
var folder=DriveApp.getFolderById('Folder ID')
//takes all files in the folder and sets the variable file
var files=folder.getFiles();
while (files.hasNext())
{
var file = files.next();
//---TAKE DATA---//
//replace with source ID
var o_ss=SpreadsheetApp.open(file);
//replace with source Sheet tab name 1 to as much as you want
var o_s_n1=o_ss.getSheetByName('tab name1');
var o_s_n2=o_ss.getSheetByName('tab name2'); //optional
//assign one ore more ranges you want to copy
var o_range1=o_s_n1.getRange('A1:A2');
var o_range2=o_s_n1.getRange('C1:C2'); //optional
//Copy the values
var o_data1=o_range1.getValues();
var o_data2=o_range2.getValues(); //optional
//---COPY DATA---//
//replace with destination ID
var sss_ss=SpreadsheetApp.openById('destination ID');
//replace with destination Sheet tab name
var sss_s=sss_ss.getSheetByName('tab name1');
//Area where to copy in the new sheet
sss_s.getRange('A1:A2').setValues(o_data1);
sss_s.getRange('C1:C2').setValues(o_data2); //optional
//closes the code until here first
SpreadsheetApp.flush();
//---DUPLIKATE SOURCE SHEET AND RENAME IT AND PUT IT IN THE DESTINATION FOLDER---//
//gets the sheet name from the old sheet
var o_ss_n=o_ss.getName();
//replace with destination Folder ID
var folder=DriveApp.getFolderById('Folder ID')
//Copy the destination sheet and name it like the old sheet
DriveApp.getFileById('destination ID').makeCopy(o_ss_n,folder);
}
}
function UPDATE() {
//LEGEND: o=Old, ss=SpreadSheet, sss=SourceSreadSheet, s=Sheet, n=Name//
//---TAKE ALL OLD SPREADSHEEDS FROM FOLDER ---//
//replace it with Folder ID where the old spreadsheets are in
var folder=DriveApp.getFolderById('Folder ID')
//takes all files in the folder and sets the variable file
var files=folder.getFiles();
while (files.hasNext())
{
var file = files.next();
//---TAKE DATA---//
//replace with source ID
var o_ss=SpreadsheetApp.open(file);
//replace with source Sheet tab name 1 to as much as you want
var o_s_n1=o_ss.getSheetByName('tab name1');
var o_s_n2=o_ss.getSheetByName('tab name2'); //optional
//assign one ore more ranges you want to copy
var o_range1=o_s_n1.getRange('A1:A2');
var o_range2=o_s_n1.getRange('C1:C2'); //optional
//Copy the values
var o_data1=o_range1.getValues();
var o_data2=o_range2.getValues(); //optional
//---COPY DATA---//
//replace with destination ID
var sss_ss=SpreadsheetApp.openById('destination ID');
//replace with destination Sheet tab name
var sss_s=sss_ss.getSheetByName('tab name1');
//Area where to copy in the new sheet
sss_s.getRange('A1:A2').setValues(o_data1);
sss_s.getRange('C1:C2').setValues(o_data2); //optional
//closes the code until here first
SpreadsheetApp.flush();
//---DUPLIKATE SOURCE SHEET AND RENAME IT AND PUT IT IN THE DESTINATION FOLDER---//
//gets the sheet name from the old sheet
var o_ss_n=o_ss.getName();
//replace with destination Folder ID
var folder=DriveApp.getFolderById('Folder ID')
//Copy the destination sheet and name it like the old sheet
DriveApp.getFileById('destination ID').makeCopy(o_ss_n,folder);
}
}
google-apps-script google-sheets google-drive-sdk
google-apps-script google-sheets google-drive-sdk
edited Dec 9 '18 at 9:38
Cœur
19.4k10116155
19.4k10116155
asked Nov 24 '18 at 20:46
KillBill_158KillBill_158
114
114
Try what you dreamt of and if you run into a specific problem, provide Minimal, Complete, and Verifiable example
– TheMaster
Nov 24 '18 at 21:41
@TheMaster I have updated my code, I do not get the repeat function, do you still have an idea? Would it be nice to work here with flush ()?
– KillBill_158
Nov 28 '18 at 16:49
You'll get the folder first > then execute this function you wrote for all the files in the folder inside the while loop. See the first example here
– TheMaster
Nov 28 '18 at 19:30
@TheMaster Now he takes all the files in a folder and copies them but he does not take the areas from the spreadsheets. what's wrong here? do you have to do that with an array?
– KillBill_158
Dec 5 '18 at 18:52
@TheMaster The code works, but it does not take the Ranges from the old tables and copies them to the new spreadsheet. where exactly is the error?
– KillBill_158
Dec 5 '18 at 20:54
|
show 2 more comments
Try what you dreamt of and if you run into a specific problem, provide Minimal, Complete, and Verifiable example
– TheMaster
Nov 24 '18 at 21:41
@TheMaster I have updated my code, I do not get the repeat function, do you still have an idea? Would it be nice to work here with flush ()?
– KillBill_158
Nov 28 '18 at 16:49
You'll get the folder first > then execute this function you wrote for all the files in the folder inside the while loop. See the first example here
– TheMaster
Nov 28 '18 at 19:30
@TheMaster Now he takes all the files in a folder and copies them but he does not take the areas from the spreadsheets. what's wrong here? do you have to do that with an array?
– KillBill_158
Dec 5 '18 at 18:52
@TheMaster The code works, but it does not take the Ranges from the old tables and copies them to the new spreadsheet. where exactly is the error?
– KillBill_158
Dec 5 '18 at 20:54
Try what you dreamt of and if you run into a specific problem, provide Minimal, Complete, and Verifiable example
– TheMaster
Nov 24 '18 at 21:41
Try what you dreamt of and if you run into a specific problem, provide Minimal, Complete, and Verifiable example
– TheMaster
Nov 24 '18 at 21:41
@TheMaster I have updated my code, I do not get the repeat function, do you still have an idea? Would it be nice to work here with flush ()?
– KillBill_158
Nov 28 '18 at 16:49
@TheMaster I have updated my code, I do not get the repeat function, do you still have an idea? Would it be nice to work here with flush ()?
– KillBill_158
Nov 28 '18 at 16:49
You'll get the folder first > then execute this function you wrote for all the files in the folder inside the while loop. See the first example here
– TheMaster
Nov 28 '18 at 19:30
You'll get the folder first > then execute this function you wrote for all the files in the folder inside the while loop. See the first example here
– TheMaster
Nov 28 '18 at 19:30
@TheMaster Now he takes all the files in a folder and copies them but he does not take the areas from the spreadsheets. what's wrong here? do you have to do that with an array?
– KillBill_158
Dec 5 '18 at 18:52
@TheMaster Now he takes all the files in a folder and copies them but he does not take the areas from the spreadsheets. what's wrong here? do you have to do that with an array?
– KillBill_158
Dec 5 '18 at 18:52
@TheMaster The code works, but it does not take the Ranges from the old tables and copies them to the new spreadsheet. where exactly is the error?
– KillBill_158
Dec 5 '18 at 20:54
@TheMaster The code works, but it does not take the Ranges from the old tables and copies them to the new spreadsheet. where exactly is the error?
– KillBill_158
Dec 5 '18 at 20:54
|
show 2 more comments
1 Answer
1
active
oldest
votes
Finally Done thx @TheMaster
function UPDATE() {
//LEGEND: o=Old, ss=SpreadSheet, sss=SourceSpreadSheet, s=Sheet, n=Name//
//---TAKE ALL OLD SPREADSHEEDS FROM FOLDER ---//
//replace it with Folder ID where the old spreadsheets are in
var folder=DriveApp.getFolderById('Folder ID')
//takes all files in the folder and sets the variable file
var files=folder.getFiles();
while (files.hasNext())
{
var file = files.next();
//---TAKE DATA---//
//replace with source ID
var o_ss=SpreadsheetApp.open(file);
//replace with source Sheet tab name 1 to as much as you want
var o_s_n1=o_ss.getSheetByName('tab name1');
var o_s_n2=o_ss.getSheetByName('tab name2'); //optional
//assign one ore more ranges you want to copy
var o_range1=o_s_n1.getRange('A1:A2');
var o_range2=o_s_n1.getRange('C1:C2'); //optional
//Copy the values
var o_data1=o_range1.getValues();
var o_data2=o_range2.getValues(); //optional
//---COPY DATA---//
//replace with destination ID
var sss_ss=SpreadsheetApp.openById('destination ID');
//replace with destination Sheet tab name
var sss_s=sss_ss.getSheetByName('tab name1');
//Area where to copy in the new sheet
sss_s.getRange('A1:A2').setValues(o_data1);
sss_s.getRange('C1:C2').setValues(o_data2); //optional
//closes the code until here first
SpreadsheetApp.flush();
//---DUPLIKATE SOURCE SHEET AND RENAME IT AND PUT IT IN THE DESTINATION FOLDER---//
//gets the sheet name from the old sheet
var o_ss_n=o_ss.getName();
//replace with destination Folder ID
var folder=DriveApp.getFolderById('Folder ID')
//Copy the destination sheet and name it like the old sheet
DriveApp.getFileById('destination ID').makeCopy(o_ss_n,folder);
}
}
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%2f53462225%2fupdating-old-formatted-spreadsheets-using-a-reformatted-spreadsheet-that-takes-t%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Finally Done thx @TheMaster
function UPDATE() {
//LEGEND: o=Old, ss=SpreadSheet, sss=SourceSpreadSheet, s=Sheet, n=Name//
//---TAKE ALL OLD SPREADSHEEDS FROM FOLDER ---//
//replace it with Folder ID where the old spreadsheets are in
var folder=DriveApp.getFolderById('Folder ID')
//takes all files in the folder and sets the variable file
var files=folder.getFiles();
while (files.hasNext())
{
var file = files.next();
//---TAKE DATA---//
//replace with source ID
var o_ss=SpreadsheetApp.open(file);
//replace with source Sheet tab name 1 to as much as you want
var o_s_n1=o_ss.getSheetByName('tab name1');
var o_s_n2=o_ss.getSheetByName('tab name2'); //optional
//assign one ore more ranges you want to copy
var o_range1=o_s_n1.getRange('A1:A2');
var o_range2=o_s_n1.getRange('C1:C2'); //optional
//Copy the values
var o_data1=o_range1.getValues();
var o_data2=o_range2.getValues(); //optional
//---COPY DATA---//
//replace with destination ID
var sss_ss=SpreadsheetApp.openById('destination ID');
//replace with destination Sheet tab name
var sss_s=sss_ss.getSheetByName('tab name1');
//Area where to copy in the new sheet
sss_s.getRange('A1:A2').setValues(o_data1);
sss_s.getRange('C1:C2').setValues(o_data2); //optional
//closes the code until here first
SpreadsheetApp.flush();
//---DUPLIKATE SOURCE SHEET AND RENAME IT AND PUT IT IN THE DESTINATION FOLDER---//
//gets the sheet name from the old sheet
var o_ss_n=o_ss.getName();
//replace with destination Folder ID
var folder=DriveApp.getFolderById('Folder ID')
//Copy the destination sheet and name it like the old sheet
DriveApp.getFileById('destination ID').makeCopy(o_ss_n,folder);
}
}
add a comment |
Finally Done thx @TheMaster
function UPDATE() {
//LEGEND: o=Old, ss=SpreadSheet, sss=SourceSpreadSheet, s=Sheet, n=Name//
//---TAKE ALL OLD SPREADSHEEDS FROM FOLDER ---//
//replace it with Folder ID where the old spreadsheets are in
var folder=DriveApp.getFolderById('Folder ID')
//takes all files in the folder and sets the variable file
var files=folder.getFiles();
while (files.hasNext())
{
var file = files.next();
//---TAKE DATA---//
//replace with source ID
var o_ss=SpreadsheetApp.open(file);
//replace with source Sheet tab name 1 to as much as you want
var o_s_n1=o_ss.getSheetByName('tab name1');
var o_s_n2=o_ss.getSheetByName('tab name2'); //optional
//assign one ore more ranges you want to copy
var o_range1=o_s_n1.getRange('A1:A2');
var o_range2=o_s_n1.getRange('C1:C2'); //optional
//Copy the values
var o_data1=o_range1.getValues();
var o_data2=o_range2.getValues(); //optional
//---COPY DATA---//
//replace with destination ID
var sss_ss=SpreadsheetApp.openById('destination ID');
//replace with destination Sheet tab name
var sss_s=sss_ss.getSheetByName('tab name1');
//Area where to copy in the new sheet
sss_s.getRange('A1:A2').setValues(o_data1);
sss_s.getRange('C1:C2').setValues(o_data2); //optional
//closes the code until here first
SpreadsheetApp.flush();
//---DUPLIKATE SOURCE SHEET AND RENAME IT AND PUT IT IN THE DESTINATION FOLDER---//
//gets the sheet name from the old sheet
var o_ss_n=o_ss.getName();
//replace with destination Folder ID
var folder=DriveApp.getFolderById('Folder ID')
//Copy the destination sheet and name it like the old sheet
DriveApp.getFileById('destination ID').makeCopy(o_ss_n,folder);
}
}
add a comment |
Finally Done thx @TheMaster
function UPDATE() {
//LEGEND: o=Old, ss=SpreadSheet, sss=SourceSpreadSheet, s=Sheet, n=Name//
//---TAKE ALL OLD SPREADSHEEDS FROM FOLDER ---//
//replace it with Folder ID where the old spreadsheets are in
var folder=DriveApp.getFolderById('Folder ID')
//takes all files in the folder and sets the variable file
var files=folder.getFiles();
while (files.hasNext())
{
var file = files.next();
//---TAKE DATA---//
//replace with source ID
var o_ss=SpreadsheetApp.open(file);
//replace with source Sheet tab name 1 to as much as you want
var o_s_n1=o_ss.getSheetByName('tab name1');
var o_s_n2=o_ss.getSheetByName('tab name2'); //optional
//assign one ore more ranges you want to copy
var o_range1=o_s_n1.getRange('A1:A2');
var o_range2=o_s_n1.getRange('C1:C2'); //optional
//Copy the values
var o_data1=o_range1.getValues();
var o_data2=o_range2.getValues(); //optional
//---COPY DATA---//
//replace with destination ID
var sss_ss=SpreadsheetApp.openById('destination ID');
//replace with destination Sheet tab name
var sss_s=sss_ss.getSheetByName('tab name1');
//Area where to copy in the new sheet
sss_s.getRange('A1:A2').setValues(o_data1);
sss_s.getRange('C1:C2').setValues(o_data2); //optional
//closes the code until here first
SpreadsheetApp.flush();
//---DUPLIKATE SOURCE SHEET AND RENAME IT AND PUT IT IN THE DESTINATION FOLDER---//
//gets the sheet name from the old sheet
var o_ss_n=o_ss.getName();
//replace with destination Folder ID
var folder=DriveApp.getFolderById('Folder ID')
//Copy the destination sheet and name it like the old sheet
DriveApp.getFileById('destination ID').makeCopy(o_ss_n,folder);
}
}
Finally Done thx @TheMaster
function UPDATE() {
//LEGEND: o=Old, ss=SpreadSheet, sss=SourceSpreadSheet, s=Sheet, n=Name//
//---TAKE ALL OLD SPREADSHEEDS FROM FOLDER ---//
//replace it with Folder ID where the old spreadsheets are in
var folder=DriveApp.getFolderById('Folder ID')
//takes all files in the folder and sets the variable file
var files=folder.getFiles();
while (files.hasNext())
{
var file = files.next();
//---TAKE DATA---//
//replace with source ID
var o_ss=SpreadsheetApp.open(file);
//replace with source Sheet tab name 1 to as much as you want
var o_s_n1=o_ss.getSheetByName('tab name1');
var o_s_n2=o_ss.getSheetByName('tab name2'); //optional
//assign one ore more ranges you want to copy
var o_range1=o_s_n1.getRange('A1:A2');
var o_range2=o_s_n1.getRange('C1:C2'); //optional
//Copy the values
var o_data1=o_range1.getValues();
var o_data2=o_range2.getValues(); //optional
//---COPY DATA---//
//replace with destination ID
var sss_ss=SpreadsheetApp.openById('destination ID');
//replace with destination Sheet tab name
var sss_s=sss_ss.getSheetByName('tab name1');
//Area where to copy in the new sheet
sss_s.getRange('A1:A2').setValues(o_data1);
sss_s.getRange('C1:C2').setValues(o_data2); //optional
//closes the code until here first
SpreadsheetApp.flush();
//---DUPLIKATE SOURCE SHEET AND RENAME IT AND PUT IT IN THE DESTINATION FOLDER---//
//gets the sheet name from the old sheet
var o_ss_n=o_ss.getName();
//replace with destination Folder ID
var folder=DriveApp.getFolderById('Folder ID')
//Copy the destination sheet and name it like the old sheet
DriveApp.getFileById('destination ID').makeCopy(o_ss_n,folder);
}
}
function UPDATE() {
//LEGEND: o=Old, ss=SpreadSheet, sss=SourceSpreadSheet, s=Sheet, n=Name//
//---TAKE ALL OLD SPREADSHEEDS FROM FOLDER ---//
//replace it with Folder ID where the old spreadsheets are in
var folder=DriveApp.getFolderById('Folder ID')
//takes all files in the folder and sets the variable file
var files=folder.getFiles();
while (files.hasNext())
{
var file = files.next();
//---TAKE DATA---//
//replace with source ID
var o_ss=SpreadsheetApp.open(file);
//replace with source Sheet tab name 1 to as much as you want
var o_s_n1=o_ss.getSheetByName('tab name1');
var o_s_n2=o_ss.getSheetByName('tab name2'); //optional
//assign one ore more ranges you want to copy
var o_range1=o_s_n1.getRange('A1:A2');
var o_range2=o_s_n1.getRange('C1:C2'); //optional
//Copy the values
var o_data1=o_range1.getValues();
var o_data2=o_range2.getValues(); //optional
//---COPY DATA---//
//replace with destination ID
var sss_ss=SpreadsheetApp.openById('destination ID');
//replace with destination Sheet tab name
var sss_s=sss_ss.getSheetByName('tab name1');
//Area where to copy in the new sheet
sss_s.getRange('A1:A2').setValues(o_data1);
sss_s.getRange('C1:C2').setValues(o_data2); //optional
//closes the code until here first
SpreadsheetApp.flush();
//---DUPLIKATE SOURCE SHEET AND RENAME IT AND PUT IT IN THE DESTINATION FOLDER---//
//gets the sheet name from the old sheet
var o_ss_n=o_ss.getName();
//replace with destination Folder ID
var folder=DriveApp.getFolderById('Folder ID')
//Copy the destination sheet and name it like the old sheet
DriveApp.getFileById('destination ID').makeCopy(o_ss_n,folder);
}
}
function UPDATE() {
//LEGEND: o=Old, ss=SpreadSheet, sss=SourceSpreadSheet, s=Sheet, n=Name//
//---TAKE ALL OLD SPREADSHEEDS FROM FOLDER ---//
//replace it with Folder ID where the old spreadsheets are in
var folder=DriveApp.getFolderById('Folder ID')
//takes all files in the folder and sets the variable file
var files=folder.getFiles();
while (files.hasNext())
{
var file = files.next();
//---TAKE DATA---//
//replace with source ID
var o_ss=SpreadsheetApp.open(file);
//replace with source Sheet tab name 1 to as much as you want
var o_s_n1=o_ss.getSheetByName('tab name1');
var o_s_n2=o_ss.getSheetByName('tab name2'); //optional
//assign one ore more ranges you want to copy
var o_range1=o_s_n1.getRange('A1:A2');
var o_range2=o_s_n1.getRange('C1:C2'); //optional
//Copy the values
var o_data1=o_range1.getValues();
var o_data2=o_range2.getValues(); //optional
//---COPY DATA---//
//replace with destination ID
var sss_ss=SpreadsheetApp.openById('destination ID');
//replace with destination Sheet tab name
var sss_s=sss_ss.getSheetByName('tab name1');
//Area where to copy in the new sheet
sss_s.getRange('A1:A2').setValues(o_data1);
sss_s.getRange('C1:C2').setValues(o_data2); //optional
//closes the code until here first
SpreadsheetApp.flush();
//---DUPLIKATE SOURCE SHEET AND RENAME IT AND PUT IT IN THE DESTINATION FOLDER---//
//gets the sheet name from the old sheet
var o_ss_n=o_ss.getName();
//replace with destination Folder ID
var folder=DriveApp.getFolderById('Folder ID')
//Copy the destination sheet and name it like the old sheet
DriveApp.getFileById('destination ID').makeCopy(o_ss_n,folder);
}
}
edited Dec 6 '18 at 15:28
answered Dec 6 '18 at 12:06
KillBill_158KillBill_158
114
114
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%2f53462225%2fupdating-old-formatted-spreadsheets-using-a-reformatted-spreadsheet-that-takes-t%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
Try what you dreamt of and if you run into a specific problem, provide Minimal, Complete, and Verifiable example
– TheMaster
Nov 24 '18 at 21:41
@TheMaster I have updated my code, I do not get the repeat function, do you still have an idea? Would it be nice to work here with flush ()?
– KillBill_158
Nov 28 '18 at 16:49
You'll get the folder first > then execute this function you wrote for all the files in the folder inside the while loop. See the first example here
– TheMaster
Nov 28 '18 at 19:30
@TheMaster Now he takes all the files in a folder and copies them but he does not take the areas from the spreadsheets. what's wrong here? do you have to do that with an array?
– KillBill_158
Dec 5 '18 at 18:52
@TheMaster The code works, but it does not take the Ranges from the old tables and copies them to the new spreadsheet. where exactly is the error?
– KillBill_158
Dec 5 '18 at 20:54