Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8794407
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T23:14:49+00:00 2026-06-13T23:14:49+00:00

I have been working on a script that allows me to modify a recently

  • 0

I have been working on a script that allows me to modify a recently created spreadsheet.
Here’s what I want to do:

  1. Create new spreadsheet
  2. Copy a sheet from current spreadsheet into new spreadsheet
  3. Replace name of new sheet in new spreadsheet.

Here is the code that I have created but when I run it I am able to create the spreadsheet but the sheet from the original spreadsheet is not copied into the new spreadsheet.Basically I am able to create the spreadsheet but once created I am not able to write on the new one. Any ideas??”

function dashboards(){
   //creates dashboards
   var ss1 = SpreadsheetApp.getActiveSpreadsheet();
   ss1.setActiveSheet(ss1.getSheetByName("Sheet1"));
   var ssNew = SpreadsheetApp.create("New spreadsheet").getId();
   var ss2 = SpreadsheetApp.openById(ssNew).setActiveSpreadsheet;
   ss1.copyTo(ssNew)
   ssNew.renameActiveSheet("newsheet");;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T23:14:50+00:00Added an answer on June 13, 2026 at 11:14 pm

    Looks like you were pretty close, but I can’t follow along all the variable references. Here is re-written version that worked for me.

    I think the main issue might be the hanging setActiveSpreadsheet call in line 6 that might have broken your variable assignments.

    Another key point to make is that you can get a reference to the sheet in the new spreadsheet back from the copyTo call

    function dashboards(){
       var ss1 = SpreadsheetApp.getActiveSpreadsheet();
       var origSheet = ss1.getSheetByName('Sheet1');
       var ssNew = SpreadsheetApp.create('New spreadsheet').getId();
       var ss2 = SpreadsheetApp.openById(ssNew);
       var newSheet = origSheet.copyTo(ss2);
       newSheet.setName('newsheet');
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have recently been working on a Pastebin script (for fun) and I've come
I have been working on a JQuery script that posts JSON to my asp.net
Recently I've been working on a Greasemonkey script that would add an image to
I have been working on a script that pulls information from a certain website.
So I have been working on writing a script that takes in input from
I have been working on a script that pulls testimonials from a database, adds
I have been working on this for some time. The script does work and
I have been working on a project in C# (.net4). Project pretty much allows
I have a script that makes barplots, and opens a new window when 6
Ok, so here's the situation. I'm working on a site that allows people to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.