Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

526
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda