+ Reply to Thread
Results 1 to 2 of 2

Run-time error '6': Overflow HELP!

Hybrid View

  1. #1
    Registered User
    Join Date
    06-25-2013
    Location
    Asia
    MS-Off Ver
    Excel 2007
    Posts
    23

    Run-time error '6': Overflow HELP!

    Hi,
    Instead of having 4 macros i decided to merge them into 1.
    It works fine when the data set is quite small, but when i have a large one now i get the error Run-time error '6' Overflow.
    The debug shows that it is Lastrow = Range("A" & Rows.Count).End(xlUp).Row that is causing the problem. Can anyone see what is wrong

    Sub Transform_Data()
    Dim x, y(), i&, j&, k&, n&, s$
    x = Sheets("TXT").Range("A3").CurrentRegion.Value
    ReDim y(1 To UBound(x, 1) * UBound(x, 2) / 10, 1 To 16): k = 5
    With CreateObject("Scripting.Dictionary")
        .CompareMode = 1
        For i = 2 To UBound(x)
            For j = 6 To UBound(x, 2)
                s = x(i, 1) & "~" & x(1, j)
                If .Exists(s) Then
                    n = .Item(s)
                Else
                    n = n + 1: .Item(s) = n
                    y(n, 1) = x(1, j): y(n, 2) = x(i, 1)
                    y(n, 3) = x(i, 2): y(n, 4) = x(i, 4)
                    y(n, 5) = x(i, 5)
                End If
                If .Exists(x(i, 3)) Then
                    k = .Item(x(i, 3))
                Else
                    k = k + 1: .Item(x(i, 3)) = k
                End If
                y(n, k) = x(i, j)
            Next j
        Next i
    End With
    With Sheets("Sheet2")
        .Range("A2:P" & .Cells(Rows.Count, 1).End(xlUp).Row + 1).ClearContents
        .Range("A2:P2").Resize(n).Value = y()
        .Activate
    End With
    
    
    
    
        Dim Lastrow As Integer
        
        Lastrow = Range("A" & Rows.Count).End(xlUp).Row
        
        Range("F2:F" & Lastrow).SpecialCells(xlCellTypeBlanks).EntireRow.Delete
        
        
        
        
    Worksheets("Master Data").Range("D2:X50000").ClearContents
    Range("Data_Macro").Copy Range("Paste_Location")
    
    
    
    
    
    Sheets("ASF").Select
        Range("A1").Select
        
    End Sub
    Kind regards and thanks a lot!!!

  2. #2
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: Run-time error '6': Overflow HELP!

    try it
    Dim Lastrow As Long

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Run-Time error 6 'Overflow'
    By guatelize in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-20-2012, 07:08 AM
  2. [SOLVED] Run-time error '6': Overflow
    By msawyer in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-14-2012, 01:29 PM
  3. Run-time error '6': Overflow
    By johnlynches in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 04-02-2012, 12:07 PM
  4. Run time error 6 Overflow?
    By ben5496 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 11-06-2011, 09:00 PM
  5. Run-time error '6': Overflow
    By magoobee in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-16-2006, 12:54 PM

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