OK, first of all, asking for code may draw people away.
Second of all, I'm not sure if I understand what you are doing here, because you seem to be providing only one example of what you want to do.
Quote:
you choose two numbers, for example 10 and 3,
number 3 stands for how many numbers each row has

10 corresponds to A and 3 corresponds to S?
So, you choose how many numbers each row has. But how many rows do you have?
Do you just generate numbers until you run out of numbers to fill another row?
In that case, you'll always have a number of rows equal to A \ S, where \ is integer division of the two numbers and no fraction/remainder is regarded.
So 10 \ 3 = 3R1 without the R1 so it is just 3.
Thirdly, random number generators will generate repeating numbers. Your program has to generate the nonrepeating number based on numbers that could repeat.
A way (not exactly simple) would require using an array containing possible numbers to use (or a collection if you like them).
The issue here: You have an array containing the numbers you want to use:
Dim Nums(9) As Integer
Nums = 0 1 2 3 4 5 6 7 8 9 'Pretend that this is your array.
Dim NumCount As Integer
NumCount = 10 'Pretend that this holds the number of numbers in your array.
Generate a random number
R = Int(Rnd * NumCount) 'Let's say R is 4, because R is a random number less than 10.
RNum = Nums(R) 'Nums(4) is 4... for now!
You then remove 4 from the array using a For Loop
For LV = R + 1 To NumCount  1
Nums(LV  1) = Nums(LV)
Loop
What this does if you step through it slowly:
0 1 2 3 4 5 6 7 8 9 (Loop goes from R + 1 which is 5, and NumCount  1 which is 9)
We take the number at the position of LV  1 (first time this is position 4) and replace it with the number at the position of LV (first time this is position 5)
so, the array will do this:
0 1 2 3 5 5 6 7 8 9
LV is incremented by 1 and the process occurs again.
When LV = 5, 0 1 2 3 5 6 6 7 8 9
When LV = 6, 0 1 2 3 5 6 7 7 8 9
When LV = 7, 0 1 2 3 5 6 7 8 8 9
When LV = 8, 0 1 2 3 5 6 7 8 9 9 (notice the number 4 is gone!)
Once you are done, reduce NumCount by 1.
NumCount = NumCount  1
Now, to generate the next random number, you do the same thing that you did earlier:
R = Int(Rnd * NumCount)
But now, NumCount is 9, so R will be a random number less than 9.
Let's say you picked 6.
RNum = Nums(R) 'Nums(6) does not correspond to 6... it corresponds to 7.
Look back at the array values after the loop.
0 1 2 3 5 6 7 8 9 9 (notice the number 4 is gone!)
Now that RNum is 6, you pick 7.
You then remove the 7 from the array using a For Loop
Remember thatt R refers to the index of the array whereas RNum refers to the random number retrieved from the array.
For LV = R + 1 To NumCount  1
Nums(LV  1) = Nums(LV)
Loop
This will remove the 7 from the array.
0 1 2 3 5 6 8 9 9 9
And you decrease the value of NumCount again to 8.
You pick another random number
R = Int(Rnd * NumCount)
This time, R must be less than 8. Let's say 4. Remember that Rnd can generate as many repeating numbers as it wants to. It is your task to ensure that numbers that you use don't repeat.
RNum = Nums(R) You can figure out which number this is, yes/no?
Remove number from the array
0 1 2 3 6 8 9 9 9 9
If you noticed all of the 9s at the top of the array, don't worry, only one can be picked from Rnd because we continually decrease the value of NumCount, ensuring that those extra 9s are at an index that is too high to be generated by the current value of NumCount.
So, you generate a bunch of random numbers and you get down to a point where you only have a few more choices left.
This is what your array *could* look like when NumCount is 3.
1 6 8 9 9 9 9 9 9 9
What numbers are left over? Why, the first three numbers are left over.
That would be 1, 6, and 8.
If NumCount is 2, you could have this.
2 9 9 9 9 9 9 9 9 9
In this case, 2 and 9 are left over, because they are the first two numbers of the array.
When NumCount is 1, what number is left over?
4 9 9 9 9 9 9 9 9 9
Answer: 4