There are a couple of suggestions in this thread. Creating a dynamic amount of rows in repeating groups
This one, in particular, seems like a good start - Creating a dynamic amount of rows in repeating groups - #2 by boston85719
I created a basic example that shows how this can be done -