Take the 2-minute tour ×
Web Applications Stack Exchange is a question and answer site for power users of web applications. It's 100% free, no registration required.

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?

share|improve this question
add comment

1 Answer 1

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)
    r.copyValuesToRange(s,2,2,1,1);
    r.clearContent();
}

Assign this script to your button.

share|improve this answer
    
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/… –  Rajiv Jun 30 at 8:02
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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