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 } }
m_tarler
Feb 05, 2025Bronze Contributor
Hi, but we are missing some information here.
I have to fill the range C2:C9 of Sheet A with data from Sheet B by repeating this action for each value in Sheet B.
What action? and also you have 8 rows on Sheet A being filled by 43 rows of Sheet B? That might be addressed as part of the "this action" but the statement indicates "this action for each value in Sheet B" so that doesn't add up either.