Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

227
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda