Is there a code for repetitive merging. Like for example I want to merge A1:B1, then again A2:B2, then A3:B3 and so forth. It goes a long way up to 500th cell A500:B500?
I am familiar with this code:
function main(workbook: ExcelScript.Workbook) {
let selectedSheet = workbook.getActiveWorksheet();
selectedSheet.getRange("A2:B2").merge(false);
selectedSheet.getRange("A2:B2").getFormat().setHorizontalAlignment(ExcelScript.HorizontalAlignment.center);
}
Are there a few lines code to apply it multiple times, to avoid actually repeating the merging of 2 cells while recording?
2
Answers
This obviously comes with caveats but the only thing I can think off is to merge the first set of cells and then copy that merge down the desired amount of rows below …
If the cells are populated, it will work because it’s going to copy formats only but not sure if that is acceptable for you or not.
You can try using the code below