I have created a button on my sheet and would like it to display the content of a hidden cell when click. I am now using the following script but it doesn't seem to be the right one as the wrong value is displayed. I want cell C2 to be displayed. Any suggestions?

function myFunction() {
 var ss = SpreadsheetApp.getActiveSpreadsheet();
 var sheet = ss.getSheetByName("Twee begrippen")  
 var range = sheet.getRange(2, 3, 1, 1);
 values = range.getValues();

The assumption on this answer is right in that the script is indeed referring to cell c2. However the information in the pop up is not correct. This has got to do with the way the information in cell C2 is generated. It is the product of a vlookup function. The value in cell B2 is looked up in a different sheet. Cell B2 however is generated by a random function. Now it appears that in some way the pop up produces an other lookup value than the one in cell C2.

Could you have a quick glance at the sheet and suggest how to overcome this hurdle? You can find the file here.

  • The link point to a published to the web spreadsheet which show the spreadsheet structure but not the formulas. Please add the relevant formulas to the question. By the way, please see this site as a community knowledge repository project rather than a discussion forum. Commented Nov 29, 2017 at 15:22

1 Answer 1


Besides some "style error" (missing var, ;) and the use of getValues() instead of getValue() the script looks to show the value of C2 from the Twee begrippen sheet. Perhaps you expect a value from another sheet, if so, you should replace Twee begrippen by the correct sheet name or use ss.getActiveSheet() to get the C2 value from the active sheet.

  • Hi Ruben, thanks for your comment. I have added some information to the question which a can't post in this comment as space is limited. Please look at the question again.
    – Servi
    Commented Nov 29, 2017 at 13:57

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.