Dear All
I have downloaded a file with macro, but everytime when I run it, the Run-Time error 6 'Overflow' appears.
I tried myself to modiy the macro, but does not help :
Error line :
For W1 = 1 To 6: If Draws.Cells(Br + 4, W1 + 1) = W Then StMas(W) = TMas(W, 1): TMas(W, 2) = 0
Macro :
Option Explicit
Public Sub Cmd1_Click()
Dim TMas(49, 2) As Integer, Br As Integer, kTeg As Integer, tTeg As Integer, StMas(49) As Byte, Br1 As Integer
Dim MaxInt As Integer, BrTeg As Long
Ans = MsgBox("Please confirm the operation and wait for 'Done' message box.", vbOKCancel)
If Ans <> vbOK Then GoTo Krai:
Application.Cursor = xlWait
DoEvents
'calculating the total number of draws entered
BrTeg = 1
Do While Not Draws.Cells(BrTeg + 4, 2) = ""
Draws.Cells(BrTeg + 4, 1) = BrTeg
BrTeg = BrTeg + 1
Loop
Draws.Range("a1") = BrTeg - 1
'Intervals table Sint and draws index table Steg
Sint.Range("a4", "ax1000") = "": Steg.Range("a4", "ax1000") = ""
Sint.Range("a2", "ax2") = ""
Sint.Range("t1") = Draws.Range("L2"): Br = 1: Steg.Range("t1") = Draws.Range("L2")
For W = 1 To 45: For W1 = 1 To 2: TMas(W, W1) = 1: Next W1, W
Do While Not Draws.Cells(Br + 4, 1) = "": tTeg = Draws.Cells(Br + 4, 1)
For W = 1 To 45
For W1 = 1 To 6
If Draws.Cells(Br + 4, W1 + 1) = W Then
TMas(W, 1) = TMas(W, 1) + 1: Sint.Cells(TMas(W, 1) + 2, W + 1) = TMas(W, 2)
Steg.Cells(TMas(W, 1) + 2, W + 1) = tTeg
TMas(W, 2) = 0
End If
Next W1
TMas(W, 2) = TMas(W, 2) + 1
Next W
Br = Br + 1
Loop
MaxInt = 0
For W = 1 To 45: Sint.Cells(2, W + 1) = TMas(W, 1) - 1
If TMas(W, 1) > MaxInt Then MaxInt = TMas(W, 1)
Next W
For W = 1 To MaxInt: Sint.Cells(W + 3, 1) = W: Steg.Cells(W + 3, 1) = W: Next W
Sint.Range("T1") = tTeg: Steg.Range("T1") = tTeg
'Current intervals table Tint
kTeg = Draws.Range("A1")
Tint.Range("a4", "ax1000") = ""
Tint.Range("t1") = kTeg: Br = 1
For W = 1 To 45: TMas(W, 1) = 0: StMas(W) = 0: Next W
Do While Not Draws.Cells(Br + 4, 1) = "": Br1 = Draws.Cells(Br + 4, 1)
Tint.Cells(Br + 3, 1) = Br
For W = 1 To 45
For W1 = 1 To 6: If Draws.Cells(Br + 4, W1 + 1) = W Then StMas(W) = TMas(W, 1): TMas(W, 2) = 0
'For W1 = 1 To 6: If Draws.Cells(Br + 4, W1 + 1) = W Then StMas(W) = TMas(W, 1) = 0
Next W1
TMas(W, 1) = TMas(W, 1) + 1
Tint.Cells(Br + 3, W + 1) = TMas(W, 1)
Next W
Br = Br + 1
Loop
Application.Cursor = xlDefault
DoEvents
MsgBox "Done.", vbOKOnly
Krai:
End Sub
Bookmarks