Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

524
Views
How to copy values and preserve formatting in Google Sheets/Apps Script?

Using AppScript the goal is to copy a range of values within a Google Spreadsheet to another range within the same sheet while preserving the already applied formatting. In particular, I have

  • merged some Cells
  • highlighted some text by making it bold
  • changed the background color of some ranges
  • applied borders to some ranges and cells

All of this information should be copied as well. Not surprisingly, if I use setValues, only the values without the formatting are copied:

function copyTable() {
  let sheet = SpreadsheetApp.getActive().getSheetByName('ExampleSheet')
  let vals = sheet.getSheetValues(2,2,9,6)
  let range = sheet.getRange(13, 2, 9, 6)
  
  range.setValues(vals)
}

Is there an easy way to extend my code such that it copies all of the formatting information as well?

To make it more clear, this is what my code does at the moment:

enter image description here

But the desired result would look like this:

enter image description here

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!