Hi all, Can anyone help me to convert this C# to VBA, this function returns a random list number that sum all equal to the given number.
Ex: Given number:100 and input: 6 then generate a list contains 6 numbers that sum to given number.
        public static List<int> RandomListByIncrementing(int digitMin, double digitMax, int targetSum, int numDigits)
        {
            if (targetSum < digitMin * numDigits || targetSum > digitMax * numDigits)
                throw new ArgumentException("Impossible!", "targetSum");
 
            List<int> ret = new List<int>(Enumerable.Repeat(digitMin, numDigits));
            List<int> indexList = new List<int>(Enumerable.Range(0, numDigits + 1));
 
            Random random = new Random();
            int index;
 
            for (int currentSum = numDigits * digitMin; currentSum < targetSum; currentSum++)
            {
                index = random.Next(0, indexList.Count - 1);
 
                if (++ret[indexList[index]] == digitMax)
                {
                    indexList.RemoveAt(index);
                }
            }
            return ret;
        }