Google sheet: Replace (_) with (Empty space) in the selected cells - google-sheets

I need to replace the (_) in the first range (Red rectangle) into a SPACE in the second range (Green rectangle).
How can i do that ? thanks in advance ❤️

try like this:
=INDEX(SUBSTITUTE(A1:A10; "_"; " "))

This would also works:
=ArrayFormula(REGEXREPLACE(A1:A,"_"," "))

Related

Google sheets conditional formatting to colour cell if the same cell in another sheet is not empty

I have 2 sheets A and B. I want sheet A to colour cells if the exact same cell in sheet B is not empty. For example if cell A1 in sheet B has a string, then cell A1 in sheet A will be coloured.
Let's say I want to do this to compare a large range, how should I go about doing this?
Example: https://docs.google.com/spreadsheets/d/1P3Ob_mclpXWmILfKwD4R6JN2wAYPUcNZlmtF9LxilV0/edit?usp=sharing
Cells A2:C2, D5 and K2 in sheet B are not empty. So the corresponding cells in sheet A will be coloured red.
You can use the following formula as a conditional formatting rule:
=NOT(ISBLANK(INDIRECT("B!"&address(row(),column()))))
(the formula in A!A2 is there to just show you what happens in sheet B)
Explanation:
Not familiar how this could be done with a custom conditional formatting formula so wait for other guys to help you out with that.
However, I can offer you a Google Apps Script solution.
The following script will check for the data range in sheet B and it will construct a color array. An element of this array will have the white hex color #ffffff" if the value in the values array is empty, or a red color #ff0000 if the value is not blank.
Then it will color sheet A based on this color array in one go. The script is relatively fast even for large ranges.
Solution / Workaround:
Don't forget to adjust "sheet A" and "sheet B" to the name of your sheets.
function colorCells(){
const ss = SpreadsheetApp.getActive();
const sheetToColor = ss.getSheetByName("sheet A");
const sheetToCheck = ss.getSheetByName("sheet B");
const bValues = sheetToCheck.getDataRange().getValues();
const aColors=bValues.map(r=>r.map(v=>v==''?"#ffffff":"#ff0000"));
sheetToColor.getRange(1,1,sheetToCheck.getLastRow(),sheetToCheck.getLastColumn()).
setBackgrounds(aColors);
}
How to use that:
Click on Tools => Scipt editor, copy, paste & save the aforementioned code and then execute it by clicking on the play button.
If you want this to work "automatically" then you can set up a time trigger to execute this function for you every n minutes.
Bonus code:
You can do the same operation but on a more user-interactive way. Again, copy, paste & save the following script to the script editor but this time don't execute it as it can work by itself.
The following script will change the color of a cell in sheet A upon user edits on the same cell in sheet B:
function onEdit(e) {
// adjust this to your needs:
const sheetToColorName = "sheet A";
const sheetToCheckName = "sheet B";
const rng = e.range;
const cell = rng.getA1Notation();
if (rng.getSheet().getName()==sheetToCheckName){
const sheetToColor = e.source.getSheetByName(sheetToColorName);
if(rng.getValue()!=''){
sheetToColor.getRange(cell).setBackground("#ff0000"); //red
}
else {
sheetToColor.getRange(cell).setBackground("#ffffff"); //white
}
}
}

How to remove extra space from the top and bottom of the UITextview in iOS?

I want to remove the extra spaces between the top , bottom and in between the text.
I've tried with this one, but it's removed all the new lines.
let newString = textView.text.replacingOccurrences(of: "\n", with: "")
Result - hellohow are youhow may i help you
Actual input:
hello
how are you
how may i help you
Expected Result:
hello
how are you
how may i help you
Thanks!
Method stringByTrimmingCharactersInSet returns a new string made by removing from both ends of the String characters contained in a given character set.
We can also just remove only whitespace, newline or both.
let newString = textView.text.trimmingCharacters(in: .whitespacesAndNewlines)
You can try this :
let new = yourTextView.text.trimmingCharacters(in : .whitespacesAndNewlines)

Merge all cells to one cell and separate with comma

I use Google Sheets, and I want to get data and create one new cell.
Example:
I have 300 rows and 4 columns, like:
1|3|2|4
5|7|6|8
9|11|10|12
...
297|299|298|300
and one cell that I need in result:
1,3,2,4,5,7,6,8,9,11,10,12...297,299,298,300
=SUBSTITUTE(TRIM(QUERY(TRANSPOSE(QUERY(TRANSPOSE(A2:D),,999^99)),,999^99)), " ", ", ")
______________________________________________________
but if you want just numbers from 1 - 300 in CSV then:
=ARRAYFORMULA(JOIN(", ", ROW(A1:A300)))
You could use Textjoin:
=TEXTJOIN(",",1,A2:D)

Leave a cell blank until data is entered in different cell in Google Sheets

Can someone help me to type this formula: =IF($F5>0,I4/$F5,0)
inside this formula: =IF(F5="","",[I-want-to-type-it-here])
The first formula =IF($F5>0,I4/$F5,0) is to calculate the profit margin, and the second is to leave the cell empty until I enter data in a different cell.
try it like this:
=IFERROR(IF($F5>0, I4/$F5, 0), )
=IF(F5="", ,
IF($F5>0, I4/$F5, 0))
=IF(F5="", , IFERROR(IF($F5>0, I4/$F5, 0),
IF($F3>0, I3/$F3, 0)))

Custom Conditional Format Google Spreadsheet

I need to format a cell if it is empty and another cell contains an specified value.
For example
IF(A = "Type 1" AND B = "")
THEN FORMAT
Try:
Conditional formatting on A1.
Apply to range:
A1:A
Custom formula is:
=and(A1="Type 1",B1="")

Resources