+ Reply to Thread
Results 1 to 2 of 2

Please help me with run-time error '6' Overflow.

  1. #1

    Please help me with run-time error '6' Overflow.

    Hi,
    I am getting an overflow error. Below is the code. Please help me
    with the fix. I am actually comparing data of two sheets and printing
    Matched/Not Matched in the third sheet.

    Sub compare()

    Dim j As Integer, k As Integer

    Set rngSheet_res = ThisWorkbook.Sheets("Compare").Range("A2:BL1000")

    For j = 2 To 1000
    For k = 1 To 100
    If ThisWorkbook.Sheets("RC").Cells(j, k).Value =
    ThisWorkbook.Sheets("FM").Cells(j, k).Value Then
    ThisWorkbook.Sheets("Compare").Cells(j, k).Value = "Matched"
    Else
    ThisWorkbook.Sheets("Compare").Cells(j, k).Value = "Not
    Matched"
    End If
    Next k
    Next j
    End Sub

    After i run this i get an overflow run-time error. When i try to denug
    this, it seems that there is an overflow in the loop for j.

    Thanks
    ~sidd


  2. #2
    Harald Staff
    Guest

    Re: Please help me with run-time error '6' Overflow.

    Hi Sidd

    Your code works fine here. But don't use Integer, they are nothing but that
    kind of problems. Replace Integer with Long, code will be better and
    slightly faster.

    HTH. Best wishes Harald

    <[email protected]> skrev i melding
    news:[email protected]...
    > Hi,
    > I am getting an overflow error. Below is the code. Please help me
    > with the fix. I am actually comparing data of two sheets and printing
    > Matched/Not Matched in the third sheet.
    >
    > Sub compare()
    >
    > Dim j As Integer, k As Integer
    >
    > Set rngSheet_res = ThisWorkbook.Sheets("Compare").Range("A2:BL1000")
    >
    > For j = 2 To 1000
    > For k = 1 To 100
    > If ThisWorkbook.Sheets("RC").Cells(j, k).Value =
    > ThisWorkbook.Sheets("FM").Cells(j, k).Value Then
    > ThisWorkbook.Sheets("Compare").Cells(j, k).Value = "Matched"
    > Else
    > ThisWorkbook.Sheets("Compare").Cells(j, k).Value = "Not
    > Matched"
    > End If
    > Next k
    > Next j
    > End Sub
    >
    > After i run this i get an overflow run-time error. When i try to denug
    > this, it seems that there is an overflow in the loop for j.
    >
    > Thanks
    > ~sidd
    >




+ 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