I want to copy/move an image from a merged cells to another sheet in one cell using Google Apps Script.
So far i've tried:
getValue()
and setValue()
- nothing happens
copyTo()
- the image retains its original size
moveTo()
- same result as copyTo()
My current code for this:
```
var sourceSheet = SpreadsheetApp.getActive().getSheetByName('Source');
var destinationSheet = SpreadsheetApp.getActive().getSheetByName('Destination');
function myFunction() {
sourceSheet.getRange('B6:B16').copyTo(destinationSheet.getRange(1, 2));
}
```
An example spreadsheet: https://docs.google.com/spreadsheets/d/1Bqf08o_DtUw1lMpjA4xAeHJQWlPNVadj9E8bRs11SfU/edit
My goal is that the image in the destinationSheet is only in one cell and not multiple cells. I don't know what else I can try and I hope someone can help me.
Although I'm not sure whether I could correctly understand your expected result, how about the following modification?
function myFunction() {
sourceSheet.getRange('B6:B16').copyTo(destinationSheet.getRange(1, 2));
}
function myFunction() {
sourceSheet.getRange('B6').copyTo(destinationSheet.getRange(1, 2));
}
or
function myFunction() {
var dstRange = destinationSheet.getRange(1, 2);
sourceSheet.getRange('B6:B16').copyTo(dstRange);
dstRange.getMergedRanges()[0].breakApart();
}
destinationSheet
.