A bot, or most any coding for that matter, cannot use variables to create variables because all variables must be defined before the play button is pressed.
I don’t know why, with the advancement of technology, this limitation still exists, but it does. It is a very practical request especially when you don’t know how many of those variables you will have per run.
I always suggest two ideas for this, 1 is practical, and 1 is just fun because it breaks all the rules and really is bots building bots.
option 1 (practical): you write to excel column A, the variable you want to build, you write to column B, the variable value you want to retrieve. In C1 you have an input cell (where the bot writes to excel the variable it wants). In D1 you have a Vlookup which is the output cell. After writing to C1, the bot reads the variable value from D1, and can write it to the predefined variable for that loop. So, it doesn’t always know it within the bot, but it can always access it later.
now the fun one. I’ve only done this once and it was 4 years ago. I built a bot that opened that went to Power Automate Desktop, made a new flow, and was put on a loop to make actions that both create and set environment variables from Col A and B above (in option 1). It then saves and closes the bot. The bot that you currently running, then runs that flow. All the variables are created as environment variables, and then you can “Get Environment Variable”.
At the end of the day, while impressive, it was still a party trick because you have to save the “get environment variable” to an actual variable within your original bot, because the variable names must all exist before you press play. So I ended up using the Excel option as it was much faster and gave me the same result.
good luck!