Hello
Adapt your formula to the following in cell D6 on the P1 sheet and drag down.

=VLOOKUP("A1", INDIRECT("'G"&ROW(A1)&"'!$B$10:$AI$24"), 4, 0)

this should follow the row numbers with the G sheet numbers. Be careful to include all the quotation marks.

Hope this helps.