+ Reply to Thread
Results 1 to 3 of 3

Overflow error with row count

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    02-15-2012
    Location
    New York
    MS-Off Ver
    Excel 2010
    Posts
    141

    Overflow error with row count

    I have a spreadsheet with 70,000 rows of data. It's well within Excel's 1 million row limit (I'm using Excel 2013), but for some reason I'm getting an overflow error in VBA when I try to count those rows. Any ideas or ways to get around this?

    Sub rowCount()
    
    Dim rowCounter As Integer
    
    rowCounter = ThisWorkbook.Sheets("Data").Cells(Rows.Count, 1).End(xlUp).Row + 1
    MsgBox rowCounter
    Last edited by kestefon; 11-07-2013 at 02:52 PM.

  2. #2
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,649

    Re: Overflow error with row count

    Change the line of code

    From

    Dim rowCounter As Integer
    To

    Dim rowCounter As Long
    Regards
    sktneer


    Treat people the way you want to be treated. Talk to people the way you want to be talked to.
    Respect is earned NOT given.

  3. #3
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2404
    Posts
    24,774

    Re: Overflow error with row count

    Declare rowCounter as Long instead of Integer. Integer maxes out at 32,767.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

+ 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. Replies: 6
    Last Post: 07-31-2012, 11:56 AM
  2. Explanation of the Run-time error '6': Overflow Error
    By mgphill in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-25-2012, 10:46 AM
  3. Want to do a while-loop but get error message: run error '6' overflow
    By danzi in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-07-2011, 01:48 PM
  4. [SOLVED] Overflow Error
    By DG in forum Excel General
    Replies: 3
    Last Post: 04-15-2005, 01:06 PM
  5. [SOLVED] Overflow Error
    By DG in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-15-2005, 01:06 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