+ Reply to Thread
Results 1 to 11 of 11

Overflow Error While Selecting The Entire Worksheet

  1. #1
    Forum Expert
    Join Date
    11-27-2007
    Location
    New Jersey, USA
    MS-Off Ver
    2013
    Posts
    1,669

    Overflow Error While Selecting The Entire Worksheet

    I have following code in the worksheet and every time I select the entire worksheet it generates an "Overflow" error.
    Just curious to know why and if anything needs to be changed in the code to allow user to select the entire sheet.

    Please Login or Register  to view this content.
    Thanks for any suggestions.

    modytrane.
    Last edited by modytrane; 01-04-2012 at 03:09 PM. Reason: Solved

  2. #2
    Forum Contributor
    Join Date
    12-28-2011
    Location
    England
    MS-Off Ver
    Excel 2007
    Posts
    280

    Re: Overflow Error While Selecting The Entire Worksheet

    Hi

    2007 has 1mill+ rows by thousands of columns - if you select the entire sheet you exceed the maximum value of the Long datatype returned by the Count function. 2007 comes with CountLarge to cater for this:

    Please Login or Register  to view this content.

  3. #3
    Forum Expert OnErrorGoto0's Avatar
    Join Date
    12-30-2011
    Location
    I DO NOT POST HERE ANYMORE
    MS-Off Ver
    I DO NOT POST HERE ANYMORE
    Posts
    1,655

    Re: Overflow Error While Selecting The Entire Worksheet

    It is due to the number of cells in the 'big grid'. You can use
    Please Login or Register  to view this content.
    instead and it should be OK.
    Good luck.

  4. #4
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Overflow Error While Selecting The Entire Worksheet

    But I think this suffices:

    Please Login or Register  to view this content.



  5. #5
    Forum Expert OnErrorGoto0's Avatar
    Join Date
    12-30-2011
    Location
    I DO NOT POST HERE ANYMORE
    MS-Off Ver
    I DO NOT POST HERE ANYMORE
    Posts
    1,655

    Re: Overflow Error While Selecting The Entire Worksheet

    It might suffice, but it is not the same code since the original one exits if more than one cell is selected. If that was not the intention, then you may be correct.
    I would also use an If...ElseIf rather than two separate If statements that cannot both be satisfied.

  6. #6
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Overflow Error While Selecting The Entire Worksheet

    @onerrorgoto0

    but it is not the same code since the original one exits if more than one cell is selected
    My alternative is just doing that.

  7. #7
    Forum Expert OnErrorGoto0's Avatar
    Join Date
    12-30-2011
    Location
    I DO NOT POST HERE ANYMORE
    MS-Off Ver
    I DO NOT POST HERE ANYMORE
    Posts
    1,655

    Re: Overflow Error While Selecting The Entire Worksheet

    @snb,
    No, it is not. If you selected the whole of column B for example, it would call your second macro, would it not?

  8. #8
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Overflow Error While Selecting The Entire Worksheet

    @onerrorgoto0

    You are right..

    maybe:
    Please Login or Register  to view this content.

  9. #9
    Forum Expert OnErrorGoto0's Avatar
    Join Date
    12-30-2011
    Location
    I DO NOT POST HERE ANYMORE
    MS-Off Ver
    I DO NOT POST HERE ANYMORE
    Posts
    1,655

    Re: Overflow Error While Selecting The Entire Worksheet

    That could still give you an overflow (though more unlikely!), so we are back to square one.

  10. #10
    Forum Expert
    Join Date
    11-27-2007
    Location
    New Jersey, USA
    MS-Off Ver
    2013
    Posts
    1,669

    Re: Overflow Error While Selecting The Entire Worksheet

    Thanks for all the replies.
    CountLarge seems to work.

    I have used the .Count<>1 in many other applications, so it's just a matter of habit. I know it probably won't matter much in this case. In other cases I needed it to make sure user doesn't select multiple cells and copy data or formulas.

    Thanks for the answers and discussion. Learned something today.

    modytrane.

  11. #11
    Forum Expert
    Join Date
    11-27-2007
    Location
    New Jersey, USA
    MS-Off Ver
    2013
    Posts
    1,669

    Re: Overflow Error While Selecting The Entire Worksheet

    Thanks for all the replies.
    CountLarge seems to work.

    I have used the .Count<>1 in many other applications, so it's just a matter of habit. I know it probably won't matter much in this case. In other cases I needed it to make sure user doesn't select multiple cells and copy data or formulas.

    Thanks for the answers and discussion. Learned something today.

    modytrane.

+ 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