Link to home
Start Free TrialLog in
Avatar of EnigmaMatter
EnigmaMatterFlag for United States of America

asked on

Excel VBA OVERFLOW ERROR

Hello,

I am receiving an error on the first line of:

For INTROW = ActiveSheet.UsedRange.Rows.Count To 6 Step -1
        With ActiveSheet
            If .Cells(INTROW, 2) + .Cells(INTROW, 4) + .Cells(INTROW, 6) + .Cells(INTROW, 8) + .Cells(INTROW, 10) + .Cells(INTROW, 12) = 0 Then .Rows(INTROW).Delete
        End With
    Next INTROW

Open in new window


It used to work, but doesn't work now, and I haven't changed anything that I know of. All it is supposed to do is delete rows where the sum of certain cells is 0, for all cells in the UsedRange.

DOes anyone know of another way to accomplish that or how to fix the above?
Avatar of zorvek (Kevin Jones)
zorvek (Kevin Jones)
Flag of United States of America image

You may have saved the workbook as a 2007 or later workbook (.xlsm) which increases the number of rows from 32K to over a million. Change INTROW from an Integer to a Long.

Kevin
You probably have

dim INTROW as integer

change it to

dim INTROW as long
I think the data size has recently exceeded 32K rows which is why the error never happened before
Avatar of EnigmaMatter

ASKER

Hello,

The workbook has always been a .xlsb, and the UsedRange is usually around 50 rows, and ususally never more than a 1000.

When I change to Long, it freezes up.
ASKER CERTIFIED SOLUTION
Avatar of Saqib Husain
Saqib Husain
Flag of Pakistan image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Ah! It took me to blank rows, quite a ways down. I "deleted" the blank rows and now it works. Thanks! Works with Integer and Long.