I want to copy 3 values from sheet1 to sheet2 using custom button on clicking on it.
I have on sheet1
A B C D F G
1 bbb kkkk 12 2 3 my custom button here
2 hhhh tttt 13 6 8 my custom button here
3 ttt qqqq 16 1 4 my custom button here
And my sheet2
A B C
1
What I want is when I click on my custom button
I want to copy values FROM the clicked buttons row ex B1 C1 F1 in sheet1 to A1 B1 C1.
I tried this
function CopyPaste() {
var sheet1 = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('sheet1');
var sheet2 = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('sheet2');
sheet1.getRange('G2').getValue().copyTo(sheet2.getRange('A45')) ;
sheet1.getRange('I2').getValue().copyTo(sheet2.getRange('B45')) ;
sheet1.getRange('K2').getValue().copyTo(sheet2.getRange('C45')) ;
}
BUT this getting always G2 I2 K2 and not the clicked row . AND from this I'm not getting the calculated value , I'm getting instead the formula script which I don't want. I want get just calculated values from sheet1 . they are calculated.