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
Select the column and try to replace with RegExp:
If you want a script, for the 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
The Condition formatting 'Countif' did not highlight the whole row even adding $.
=Countif($H$3:$H$9,H3)>1
Did I miss something?
Thanks.
Apply to range: H3:I10
Formula: =Countif($H$3:$H$10,$H3)>1
Im sorry I dont even know how to correctly phrase this question.
The line of code I need to edit is this;
sheet.getRange(targetcell).setValue('=INDEX(QUERY(IMPORTHTML("http://www.futbin.com/consumables/Position%20Change","table",2),"select Col2"),1)');
However instead of row 1, I want to use the value from cell G1. So, something like this;
sheet.getRange(targetcell).setValue('=INDEX(QUERY(IMPORTHTML("http://www.futbin.com/consumables/Position%20Change","table",2),"select Col2"),G1)');
However, this throws an error.
Could anyone advise how I can use the value in G1 instead of it being fixed?
Thank you.
Try .setFormula instead of .setValue ...
sheet.getRange(targetcell).setFormula('=INDEX(QUERY(IMPORTHTML("http://www.futbin.com/consumables/Position%20Change","table",2),"select Col2"),G1)');
If there were a column G from the table that results from that IMPORTHTML function then you would use this:
sheet.getRange(targetcell).setValue('=INDEX(QUERY(IMPORTHTML("http://www.futbin.com/consumables/Position%20Change","table",2),"select Col7"),1)');
Because G is column 7
However, there is only 3 columns from that IMPORTHTML. You can check this by entering the formular into a Google Sheet:
=IMPORTHTML("http://www.futbin.com/consumables/Position%20Change","table",2)
I suggest playing around with your formula in SHeets and once you've got what you want, go back into AppsScript.
I am trying to determine if there is a specific string of data in a cell. so if have a cell that says 1 2 3 4 5 6. Using the Space as a delimiter. is there a way for me to query the 4 out of it? and get a return of the 4?
I have tried using search and find but thats are just giving me the len position within the cell.
So, use find(), which you say you did but did not show how...
What about:
=if(iferror(find(A1,B1,1),0)>0,A1,"Not found")
I've setup my sheet like so:
The formula works like so:
mid(A2, //grab a substring from the middle of A2
SEARCH("4",A2) //find the value "4" inside A2
,1) //make MID grab exactly one character (length of string "4"
With some jimmying, you can generalize this however you want.
try:
=REGEXEXTRACT(A1&""; "\b4")
Another solution for Google Sheets:
=if(iserror(MATCH(A1,SPLIT(B1," "),0)),"",A1)
(aka: look for A1 in B1)
enjoy
I was sure to find that on StackOverflow but finally no. Maybe it's not possible?
I'd like to get the cell where my function is running.
If for example I have the function that is repeated in column D for line 1 to 10, I'd like that function to know that the current "processing" is D4 (for example).
I want this in order to be able to change the color of the cell based on the computation the function does. This, of course, changes based on the data input.
Is this possible? How? I wasn't able to find it.
Here's an applicable example code :
function ALERT_IF_NEGATIVE(input) {
if (input < 0) {
// Set that cell's color to red
}
}
Thank you.
Conditional formatting will solve this.
https://support.google.com/docs/answer/78413?hl=en
This is an example I have from a spreadsheet I use:
In my code it adds the row values:
ss.appendRow([account,sAccount.name,sAccount.id,response.access_token,d,expTime,'=if(E'+lastRow+'<NOW(), "EXPIRED","VALID")',]);`
In this case the formula in column 'G' looks at a timestamp in Column 'E' and sets the value in 'G'. The conditional format looks at the values in 'G' and changes the cells background color based on the value.
The formatting is recalculated when there is a change to the sheet, or can be set-up to recalculate on a timer in File->Spreadsheet settings.
I have a simple ImportXml function in Google spreadsheet:
=ImportXml( "http://www.google.com/finance?q=0322.hk", "//span[#class='chr']" )
but it is giving me 2 cells of data, the cell direction underneath it is a =Continue(blah blah)... automatically placed by Google.
Here is the HTML code associated with this page. Looks like it has 2 items. I've replaced "<" & ">" with "(" & ")"
(span class="ch bld")(span class="chr" id="ref_673324_c")-0.45(/span)
(span class="chr" id="ref_673324_cp")(-2.02%)(/span)
How do I change my ImportXml function so that I'm only importing the "-0.45" without the "(-2.02%)?
I've also found that the INDEX command works... useful too if you want the 2nd (-2.02%) item in the results. One important note, though, is that you've got to first transpose the output of ImportXML or it won't work.
=INDEX( TRANSPOSE (ImportXML (...)), {num}) where num is the desired result.
I found a work around... I put =NOEXPAND function infront of it and it works. but if anybody has another solution let me know.