Forum Discussion
Dan1ExcelUser
Feb 05, 2025Copper Contributor
How to fill a range of Sheet A with data from Sheet B by repeating this action for each value
Hi, I have two sheets A & B. Sheet A has a table where A1:H1 is the header. The range C2:C9 of this table is blank but there is data in the ranges A2:B9 and D2:H9. Sheet B has data in the range A...
- Feb 10, 2025
As variant
function main(workbook: ExcelScript.Workbook) { const data = workbook.getWorksheet("SheetB") .getUsedRange().getValues().slice(1) const range = workbook.getWorksheet("SheetA") .getRange("A2:H10") let i = 0 for (let item of data) { let next = range.getOffsetRange(9 * i, 0) i > 0 ? next.copyFrom(range) : '' next.getColumn(2).setValues(item[0]) i += 1 } }
Patrick2788
Feb 10, 2025Silver Contributor
I don't see any reason why m_tarler 's solution does not accomplish this task. If each item is not repeated a fixed amount of times then something more sophisticated would need to be done. From what I gather with your example, it's fixed at 9 times each.
Dan1ExcelUser
Feb 12, 2025Copper Contributor
Ok I understand but it doesn't work for me.