Google-sheets – How to pull the page number and the number of images listed from one sheet and then populate cells in another sheet accordingly

formulasgoogle sheetsgoogle-sheets-arrayformulagoogle-sheets-queryworksheet-function

Sorry, I didn't know how to summarize it in the title. Basically, I have a spreadsheet where I'm keeping track of the number of images that need to be on each page of a document I'm working on.

On the first tab, I have a sheet to keep track of how many images are on each page. On the second tab, I have a sheet to write out what the image concept is for each image. To keep track of which page and image number it is, I've been writing them as [page #] – [image #] on the second tab.

Tab 1 Tab 2

This is super time-consuming, and so far the best solution I've come up with is to copy and paste a column of 5 rows that say x-1, x-2, x-3, etc and then select them and do a find and replace x for the page number.

I'm wondering if there's a way I can pull the page number from Tab 1 and the number of images listed and then populate cells in Tab 2 accordingly.

e.g. – Cell with page number 11 + cell with image number 4 would produce 4 rows with:

  • 11-1
  • 11-2
  • 11-3
  • 11-4

Thanks in advance!

EDIT: Here's a link to a copy of the spreadsheet

Best Answer

  • create a hidden auxiliary sheet (let's call it AUX)
  • paste this formula into A1 and drag down (when done - hide sheet)

    =IF(LEN(Main!A1), ARRAYFORMULA(IFERROR(TO_TEXT(TRANSPOSE(
     SPLIT(Main!A1&"-"&ROW(INDIRECT("A1:A"&Main!B1))&" ", " "))), )), )


  • paste this formula into cell A1 on Concepts sheet

    ={QUERY({AUX!A1:A8;AUX!B1:B8;AUX!C1:C8;AUX!D1:D8;AUX!E1:E8}, 
      "select Col1 where Col1 is not NULL", 0);
      QUERY({AUX!A9:A;AUX!B9:B;AUX!C9:C;AUX!D9:D;AUX!E9:E}, 
      "select Col1 where Col1 is not NULL", 0)}