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

235
Vistas
Google Sheets script – replace blank spaces

I've got a script that's doing some onEdit formatting on a sheet of mine. All the rest is working well, and I wanted to include a line that deletes spaces from number values I'm importing. That last line is not working.

Any ideas what I'm missing here?

function onEdit(e) {
  var cell = e.range;
  var sh = e.source.getActiveSheet();  
  if(sh.getName() === "Trading Journal") {
    cell.setBackground('#fff');
    cell.setFontSize(10)
    cell.setFontFamily()
    cell.replace(/\s/g, "") 
}
}

https://docs.google.com/spreadsheets/d/1rkjO-ITeLdIHq-LLHfHcp6-1j1R0-giS6HGbwYdJ5Ek/edit?usp=sharing

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Did a bit of research regarding this, and it seems that .replace() is a string method and therefore may not work with numbers. Reference

But if you only need to remove whitespaces from numbers, here is a simple solution:

function rSpaces() {
    var ss =  SpreadsheetApp.getActiveSpreadsheet();
    var cell = ss.getActiveCell();
    cell.trimWhitespace();
}

You can assign this on an onEdit trigger and check this documentation for any font modifications you want to add.

about 4 years ago · Juan Pablo Isaza Denunciar
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