I use Google Sheets to produce simple quizzes for students. Instead of just having a cell display <Good!> when a kid enters a correct answer, I'd like to make a drawing pop up. A sports fan cheering, with a speech bubble, say. Google's documentation shows I can use GAS to change the size and position of a drawing, and thereby presumably make it go from effectively hidden to conspicuous. I don't foresee a problem when there's only one drawing, but if I have several, I don't see an easy way of selecting one.

I can get an array of the drawings in a sheet using getDrawings(), and use getContainerInfo() to find where the drawing is, and identify it that way, but that's pretty clunky: my code won't give any indication of what drawing is at a particular position, and if I accidentally move the drawing, my script won't select it.

Right now I'm thinking of using setOnAction() with a name that isn't actually the name of a macro, and looping through the drawings array until getOnAction() returns the name I want, but I don't know if the compiler will be happy assigning arbitrary strings via setOnAction(). I wonder if there isn't a cleaner way to do this.

1 Answer 1


One way to show and hide images is to use a spreadsheet formula that uses the image() function wrapped in an if() or ifs(). This requires that the images are reachable through a public URL.

Another way is to Insert > Image > Image in cell and then use Sheet.unhideRow() and Sheet.hideRow() to choose whether the image is visible.

Both of these methods embed images in cells which means that image size will be limited by cell size. You may need to resize particular rows and columns to make images bigger.

  • That would work, but it wouldn't allow you to move the image around if desired. It would also have odd effects if you have stuff on a row below that.
    – Robert M.
    Jun 9 at 3:49

Your Answer

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

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