My Problem
I have a column of data for users to input text, and it is highly expected that they should add a plus or minus before text, which would result in an error.
For example, they are often shown a string like "+1d4+2", which they are expected to copy and type into the cells, which if they do so, would result in an error.
Typical suggestions such as adding an apostrophe before the + or - sign to prevent the generation of a formula would not work in this context, since users are not expected to understand how to interact with this.
What I've Already Tried
Number Formatting of the Range as Plain Text
One suggestion was to format the range as Plain Text, but I did not see that this prevented a +/- from generating a formula.
Apps Script Code
I saw a code that would look extremely useful posted by a user called Sahil Singh on this answer. I followed all the instructions he gave, but when I run the code, it doesn't work because it says 'Column' is not defined. I know how to refer to a range using VBA in Excel, but not in App Scripts.
function columnToLetter(column){ var temp, letter = ''; while (column > 0) { temp = (column - 1) % 26; letter = String.fromCharCode(temp + 65) + letter; column = (column - temp - 1) / 26; } return letter;}function letterToColumn(letter){ var column = 0, length = letter.length; for (var i = 0; i < length; i++) { column += (letter.charCodeAt(i) - 64) * Math.pow(26, length - i - 1); } return column;}function main() { var sheet = SpreadsheetApp.getActiveSheet(); var data = sheet.getDataRange().getValues(); Logger.log(data) for (var i = 0; i < data.length; i++) { for (var j=0;j<data[i].length;j++) if(data[i][j]=="#NAME?") { var clm=columnToLetter(j+1); var rng=clm+String(i+1); var range = sheet.getRange(rng); var frml = range.getFormula(); range.setValue("'+"+frml.substring(1)); Logger.log("sahil#"+frml); } Logger.log(data[i][j]); }}