Excel Problem with Int vs String

Joined
Mar 22, 2011
Messages
1
Reaction score
0
Before I ask my question I am new to VBA programming so please be gentle :o

I am writing a Macro that will determine the number of rows, Calculate a specific number of rows, determine the row number and than copy specific columns within those chosen rows. I can do everything else and I have excluded the non-important code from this post. What I need help to do is

When I try to split the random numbers and place them into an Array as a integer, it breaks apart and does not seem to work. Any help would be great appreciated.

I have included the random creating function (I did not write it) and my source code.
Code:
Sub funny_trans()

Sheets("Sheet1").Select

Dim TotalCount As Integer, TotalCount2 As Integer, TotalCount3() As Integer, Counter As Integer

TotalCount = ActiveSheet.UsedRange.Rows.Count
TotalCount2 = WorksheetFunction.Sum(TotalCount * 0.2)

If (TotalCount2 <= 9) Then TotalCount2 = 10
If (TotalCount2 >= 51) Then TotalCount2 = 50

Random_Numbers = RandLotto(2, TotalCount, TotalCount2)

TotalCount3() = Int(Split(Random_Numbers, " "))

End Sub



Function RandLotto(Bottom As Integer, Top As Integer, Amount As Integer) As String
    Dim iArr As Variant
    Dim i As Integer
    Dim r As Integer
    Dim temp As Integer

    Application.Volatile
    ReDim iArr(Bottom To Top)
    For i = Bottom To Top
        iArr(i) = i
    Next i
   
    For i = Top To Bottom + 1 Step -1
        r = Int(Rnd() * (i - Bottom + 1)) + Bottom
        temp = iArr(r)
        iArr(r) = iArr(i)
        iArr(i) = temp
    Next i

    For i = Bottom To Bottom + Amount - 1
        RandLotto = RandLotto & " " & iArr(i)
    Next i
    
    RandLotto = Trim(RandLotto)
End Function
 
Back
Top