Issue with changing Selected Rows with a variable

I have 4 tasks in my experiment, I have an outer loop that randomizes the order of the 4 tasks. Then an inner loop that runs the trials. In my excel file, I have 8 rows of training stimuli, and then a second 8 rows of testing stimuli. I want the first 8 rows (training) to cycle through 4 times, and then the selected rows to change to the next 8 rows and cycle through twice.

The way I have tried to do this is by putting $Block in the Selected Rows space.
In a Begin Routine tab I have the code below, in which trials is the name of the loop.

if trials.thisRepN < 4:
    Block = '0:8'
if trials.thisRepN > 3:
    Block = '8:16'

I know to some extent this is working, because I have it printing whatever Block is in my data file. So it is correctly reporting in the data file 0:8 for the first 4 iterations, and then 8:16 on the last 2 iterations. What is odd, is that it’s not actually showing rows 8:16 when I run the program. It is still showing the training stimuli from rows 0:8? I am not sure why that is?
Any advice would be appreciated.

Thanks,
Brooke

Hi, if I’ve understood what you’re trying to achieve correctly, I believe this minimal demo should do the trick
change blocks.zip (20.2 KB)