+ Reply to Thread
Results 1 to 2 of 2

Run-Time error '6'

  1. #1
    Registered User
    Join Date
    09-04-2008
    Location
    Europe
    Posts
    12

    Exclamation Run-Time error '6'

    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

  2. #2
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Run-Time error '6'

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here
    Josie

    if at first you don't succeed try doing it the way your wife told you to

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1