Is there a way to force cells in google sheet to end with 'enter'? If I'm updating a sheet, I can input a string in cell A1 ... then use the right arrow to move to the B1. Sometimes this is preferable because entering a string and then pressing enter moves the selection cell down to A2 instead of across. The problem is without the invisible 'enter' marker, it messes formatting when combining cells via scripts.
Asked
Active
Viewed 353 times
0
-
can you give an example of `it messes formatting when combining cells via scripts.`? – kaza Sep 11 '17 at 22:42
-
I'm pushing the spreadsheet into Google contacts. Address is split into 2 columns: street + city. If the street cell has 'enter' as end of line then `setAddress(street + city);` gives me street on line 1 and then city on line 2 of the addressField in Google contacts. If the street cell does not have the 'enter' character then I get 'streetcity' on one line without any space in between. – testing123 Sep 12 '17 at 00:36
1 Answers
0
I would do the below...
setAddress(street.trim()+'\n'+ city.trim());
\n
is a new line character.
street.trim()
would trim any new line characters if there are any.

kaza
- 2,317
- 1
- 16
- 25
-
I get a ReferenceError: "TRIM" is not defined. Same with 'char'. Guess GAS doesn't understand it ... – testing123 Sep 12 '17 at 01:20
-
Just realised that you are using it in the script and not calling from sheets as a user defined function. So changed answer accordingly. – kaza Sep 12 '17 at 01:48