I have numeric co-variates in groups of 1, 2, 3, 4, 5, 6, etc.

Each group corresponds to a study I conducted

I'm trying to find all possible combinations of each study's group of co-variates - for example, if study 1 has corresponding co-variates 8, 3, 7.... then I want to find 3C2... so (8, 3) would be the first 2character group; (8, 7) would be the 2nd 2character group; and so on...

In Excel, I have my "studies" in row 1, and then the "groups of co-variates" corresponding to each study in row 2, and then I have the groups I want to combine them into (i.e., r=2, 3, 4, etc.) in the subsequent rows

I'm wondering if there is a macro I could use for this?

I'm attaching a sample of my data to give a better idea of exactly what I'm trying to achieve - I've manually created the combinations for "study 3".

My data is quite large, and I'm really hoping to be able to create a UDF whereby I can just enter the function name (e.g., Combinations), select the range (i.e., the single group of co-variates corresponding to the study), and then enter the "r" I need

Sorry if the above doesn't make sense, I'm quite new to VBA but think it may be my best option here! - feel free to ask any questions, all help is greatly appreciated as I really need to find a Macro to help me perform this function quickly!!!

Thank you in advance

Sample data.xlsx