I want a user to be able to click on a button and have the value of one cell go into another cell.

How can I do this?


Adapt this script to transfer value of A1 to B1:

function transfer() {
    var s = SpreadsheetApp.getActiveSheet();
    r = s.getRange("A1");
    // copyValuesToRange method will copy value in A1 to B1(range of B1 - 2,2,1,1)

Assign this script to your button.

  • Can I ask what the 2,2,1,1 is for?? why is it not: r.copyValuesToRange(s,"B2"); Please help.
    – user24949
    Sep 27 '12 at 1:36
  • Thanks a lot for this script. Is is possible to set the getRange as variable? I have all values in column A (A1:A100) I want to click (for example) cell A12 and the value of A12 should appear in cell L1. If I click cell A51 it should also be copied by click into cell L1.
    – user25167
    Oct 2 '12 at 15:23
  • @user24949 This should answer your question about the 2,2,1,1 developers.google.com/apps-script/reference/spreadsheet/…
    – user72961
    Jun 30 '14 at 8:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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