0

I'm collecting one-letter responses from users in a Google Sheet and would like their responses to be made uppercase as they are input, but only within the cells D5-J[infinity]. I found a few responses on how to do this and Frankensteined the following code in Script Editor, but it's not firing. What's wrong?

function onEdit(e) {
  var column = e.range.getColumn();
  var row = e.range.getRow();

  if ( col >=  4 && col <= 10 ) {
    if ( row >= 5 ) {
      if (typeof e.value != 'object') {
        e.range.setValue(e.value.toUpperCase());
      }
    }
  }
}
4
  • 1
    How are you collecting the responses? Are the users directly typing them in the spreadsheet? Commented Jan 4, 2020 at 6:10
  • Yes, Ruben. But it doesn't matter because I figured it out myself :):) The problem was that I was using two different sources for my code. One used the variable col and the other used column. Works like a charm now :)
    – TheAfroSam
    Commented Jan 4, 2020 at 16:58
  • Please post the fix you mention as an answer. Commented Jan 4, 2020 at 17:06
  • At the bottom of this page there is a "Post your answer" button. Use it to post your solution if you think that it will be helpful for someone else. If you think that it will not be helpful for anyone, you could delete it. Commented Jan 5, 2020 at 18:17

1 Answer 1

1

I realized that the problem was just that I defined the variable for the columns as "column" but then used a different variable in the code: "col". Simple user error. :)

The correct formula is as follows:

function onEdit(e) {
  var column = e.range.getColumn();
  var row = e.range.getRow();

  if ( column >=  4 && col <= 10 ) {
    if ( row >= 5 ) {
      if (typeof e.value != 'object') {
        e.range.setValue(e.value.toUpperCase());
      }
    }
  }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.