Home > Software engineering >  Change text in a negative number in Google sheets with apps Script
Change text in a negative number in Google sheets with apps Script

Time:07-30

From an export file I get the following data in a column. €9,08 € 8,67- €6,82 €10,87 € 7,23-

The negative ones are text and the positive ones are numbers. I want the text rows to be a negative number. Can someone help me how I can solve this. Thank you very much for the help. GJM

CodePudding user response:

Select the column and try to replace with RegExp:

enter image description here

If you want a script, for simplest case it could be this:

function myFunction() {
  SpreadsheetApp.getActiveSheet()
  .getRange('A:A')
  .createTextFinder('(. ?)(-)')
  .useRegularExpression(true)
  .replaceAllWith('$2$1');
}

It will make the same changes in column 'A'.

  • Related