+ Reply to Thread
Results 1 to 27 of 27

VB application stops generating spreadsheet at row 65536

  1. #1
    Registered User
    Join Date
    12-03-2012
    Location
    Perth, Australia
    MS-Off Ver
    Excel 2010
    Posts
    13

    VB application stops generating spreadsheet at row 65536

    Hello
    I have a VB application that's been running for the last couple of years on a machine that has Office 2010 installed. Now that the number of rows generated in the spreadsheet is > 65536, the application stops at this point.

    I can't work out why this is happening, the reference used is Microsoft Excel 14.0 Object library.

    Here's a snippet of the code, if any more is required, please let me know:

    Please Login or Register  to view this content.
    Does anyone know why this is happening? Any help would be greatly appreciated.

    Thank you.
    Last edited by alansidman; 11-04-2015 at 08:50 PM. Reason: added code tags

  2. #2
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,527

    Re: VB application stopps generating spreadsheet at row 65536

    Hi TerryDav,

    You need to wrap your code with the appropriate tags as per forum rule 3 (refer here). Thanks.

    The number of rows was increased from 65,536 to 1,048,576 with the release of Excel 2007 so the larger number of rows have been available for a while. I see no reason why the above is failing due to that - are there any row variables defines as integer?

    Robert
    ____________________________________________
    Please ensure you mark your thread as Solved once it is. Click here to see how
    If this post helps, please don't forget to say thanks by clicking the star icon in the bottom left-hand corner of my post

  3. #3
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: VB application stopps generating spreadsheet at row 65536

    Tested your code and for me it's creating workbook with 10,48,576 rows.

    Not sure what's wrong happening at your end


    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
    Mark your thread as Solved


    If the suggestion helps you, then Click *below to Add Reputation

  4. #4
    Registered User
    Join Date
    12-03-2012
    Location
    Perth, Australia
    MS-Off Ver
    Excel 2010
    Posts
    13

    Re: VB application stopps generating spreadsheet at row 65536

    Thanks for the replies.

    There are no integer variables, all are long. The spreadsheet opens with 1,048,576 rows but the application stops at the 65,536th row.

    I just had a thought. The application is running on a Windows Server 2003 (32bit) machine with Office 2010 (32 bit) installed. I don't suppose it's anything to do with the 32bit operating system.

    Thank you.

  5. #5
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: VB application stopps generating spreadsheet at row 65536

    Quote Originally Posted by TerryDav View Post
    The spreadsheet opens with 1,048,576 rows but the application stops at the 65,536th row.
    Then you have to share that code with us which may help us in fixing your issue

  6. #6
    Registered User
    Join Date
    12-03-2012
    Location
    Perth, Australia
    MS-Off Ver
    Excel 2010
    Posts
    13

    Re: VB application stopps generating spreadsheet at row 65536

    Here's the code
    Please Login or Register  to view this content.
    Last edited by TerryDav; 11-04-2015 at 02:25 AM.

  7. #7
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: VB application stops generating spreadsheet at row 65536

    What is the value of k?

  8. #8
    Registered User
    Join Date
    12-03-2012
    Location
    Perth, Australia
    MS-Off Ver
    Excel 2010
    Posts
    13

    Re: VB application stops generating spreadsheet at row 65536

    Thanks again for the help
    When the application stops, k is 65536, k is dimmed as Long.
    Cheers.

  9. #9
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: VB application stops generating spreadsheet at row 65536

    Where/how are you running this code?
    If posting code please use code tags, see here.

  10. #10
    Registered User
    Join Date
    12-03-2012
    Location
    Perth, Australia
    MS-Off Ver
    Excel 2010
    Posts
    13

    Re: VB application stops generating spreadsheet at row 65536

    An exe deployed to a Windows 2003 server. The server has Office 2010 32 bit installed on it. A scheduled task runs this every night.

  11. #11
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,527

    Re: VB application stops generating spreadsheet at row 65536

    Also what are you trying to write into the various columns with the WriteRow macro i.e. what is trying to be returned to cell A2 of the active sheet with this line??:

    Please Login or Register  to view this content.
    You also said you're using early binding for Microsoft Excel 14.0 Object library which is for Microsoft Excel 2010 running on Windows 7. Are you sure the specs of the server are the same (it would seem Excel 2003 is on it as this was the last version of Excel with the 65,536 row limit).

    How many rows are physically on any sheet (you can check this via clicking on any blank column and then pressing the End key followed by the Down Arrow key) from the new workbook the macro creates?
    Last edited by Trebor76; 11-04-2015 at 07:52 PM.

  12. #12
    Registered User
    Join Date
    12-03-2012
    Location
    Perth, Australia
    MS-Off Ver
    Excel 2010
    Posts
    13

    Re: VB application stops generating spreadsheet at row 65536

    Area is a string variable, so are all the other variables in the various columns except DocNumber, it's a long variable.

  13. #13
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,527

    Re: VB application stops generating spreadsheet at row 65536

    How many rows are physically on any sheet (you can check this via clicking on any blank column and then pressing the End key followed by the Down Arrow key) from the new workbook the macro creates?
    So how many rows are there?

  14. #14
    Registered User
    Join Date
    12-03-2012
    Location
    Perth, Australia
    MS-Off Ver
    Excel 2010
    Posts
    13

    Re: VB application stops generating spreadsheet at row 65536

    The spreadsheet opens with 1,048,576 rows but the application stops at the 65,536th row.

  15. #15
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,527

    Re: VB application stops generating spreadsheet at row 65536

    Area is a string variable, so are all the other variables in the various columns except DocNumber, it's a long variable.
    What is the code (or manual procedure) to assign the range to these string variables?

  16. #16
    Registered User
    Join Date
    12-03-2012
    Location
    Perth, Australia
    MS-Off Ver
    Excel 2010
    Posts
    13

    Re: VB application stops generating spreadsheet at row 65536

    Is this the code you're after, pSearch is a document management (eDocs) object. When I stepped through the code, pSearch.GetRowsFound has > 65536 records so it doesn't look like this object that's causing the problem.

    Please Login or Register  to view this content.

  17. #17
    Forum Contributor Obsessed's Avatar
    Join Date
    05-22-2013
    Location
    Cincinnati, Ohio
    MS-Off Ver
    Excel 365
    Posts
    215

    Re: VB application stops generating spreadsheet at row 65536

    Are you saving the file as a .xlsx first? if you're creating a workbook that is .xls, it doesn't matter what version of Excel you're running, it will limit the rows to 65536. I'd make sure your default workbook type is .xlsx.
    Want to show appreciation for the help you received from a member? Give them reps by clicking the bottom left of their post!

  18. #18
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,527

    Re: VB application stops generating spreadsheet at row 65536

    Not really sure then - maybe it's a string limitation though how can Area (which is for Area_Code) be returning so many records?? Maybe these variables need to be defined as a recordset?

    Good luck with it.

    Robert

  19. #19
    Registered User
    Join Date
    12-03-2012
    Location
    Perth, Australia
    MS-Off Ver
    Excel 2010
    Posts
    13

    Re: VB application stops generating spreadsheet at row 65536

    File not saved until the end of the application, hasn't got to that point at the stage where it stops. When it is saved, after all the rows have been written, it is saved as an xlsx file.

  20. #20
    Forum Contributor Obsessed's Avatar
    Join Date
    05-22-2013
    Location
    Cincinnati, Ohio
    MS-Off Ver
    Excel 365
    Posts
    215

    Re: VB application stops generating spreadsheet at row 65536

    What is the default file for your Excel though? Try saving it first, run it, then resave. When Excel creates new workbook, it will create it in its default workbook file type (XLS, XLSX, XLSB, etc), and if it happens to be XLS, it will only allow 65k rows UNTIL the workbook is saved as an XLSX, in which it will allow more. Try saving it as an XLSX immediately after creating it, and then let the code finish and resave at the end.

  21. #21
    Registered User
    Join Date
    12-03-2012
    Location
    Perth, Australia
    MS-Off Ver
    Excel 2010
    Posts
    13

    Re: VB application stops generating spreadsheet at row 65536

    Thanks for all your help, it's really appreciated. The default save format is xlsx, I checked in the settings. Also when I opened Excel and then clicked on save, the save as type shows as xlsx.

  22. #22
    Forum Contributor Obsessed's Avatar
    Join Date
    05-22-2013
    Location
    Cincinnati, Ohio
    MS-Off Ver
    Excel 365
    Posts
    215

    Re: VB application stops generating spreadsheet at row 65536

    Sorry...worth a shot.

  23. #23
    Registered User
    Join Date
    12-03-2012
    Location
    Perth, Australia
    MS-Off Ver
    Excel 2010
    Posts
    13

    Re: VB application stops generating spreadsheet at row 65536

    Do you think it's anything to do with the OS being Windows Server 2003?

  24. #24
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: VB application stops generating spreadsheet at row 65536

    Hello TerryDav,

    I had s similar problem awhile ago. I discovered that the original workbook was saved as an xls and the newer files it created were saved as xlsm. While the newer version should have referenced beyond 65536 rows, it did not. Although 2007 and later is backward compatible with earlier versions of Excel, the earlier Excel versions still retain their original file limits despite the new extension. I suspect the same is true for files created on a Excel 2003 server.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  25. #25
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,527

    Re: VB application stops generating spreadsheet at row 65536

    I wonder if it's got to do with this line...

    Please Login or Register  to view this content.
    ...as you can't specify the format when using SaveCopyAs and it's still in Excel 2003 mode.

    Comment out that line (so it's there in case the following doesn't work) and try this instead:

    Please Login or Register  to view this content.
    Regards,

    Robert
    Last edited by Trebor76; 11-05-2015 at 12:40 AM.

  26. #26
    Registered User
    Join Date
    12-03-2012
    Location
    Perth, Australia
    MS-Off Ver
    Excel 2010
    Posts
    13

    Re: VB application stops generating spreadsheet at row 65536

    Thanks for the continued responses.
    I can see how it can be this line of code because it doesn't get to that point in the code? The application doesn't save the spreadsheet it stops at row 65536 and just hangs there, doesn't save the spreadsheet.

  27. #27
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,527

    Re: VB application stops generating spreadsheet at row 65536

    OK - what about if you open a blank workbook and put the following code onto it:

    Please Login or Register  to view this content.
    If that works save it as a macro enabled workbook and use that (you could save it read-only to preserve it) as I can only guess it's go to do with fetching a new workbook from the new instance of Excel being created via the code.

    If that doesn't work I'm out of ideas I'm afraid

    Robert

+ 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. Generating Reports from Spreadsheet
    By sadele89 in forum Excel General
    Replies: 6
    Last Post: 10-24-2015, 03:37 PM
  2. Generating a csv in the same folder as spreadsheet using VBA
    By babytigress in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-05-2014, 08:19 PM
  3. help generating a new spreadsheet from an existing spreadsheet
    By dan_fash in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 01-01-2014, 10:06 PM
  4. Replies: 0
    Last Post: 07-29-2011, 06:25 PM
  5. Replies: 0
    Last Post: 03-01-2011, 11:55 AM
  6. [SOLVED]check row 65536 in spreadsheet
    By burugudug in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-18-2010, 12:49 PM
  7. [SOLVED] Generating Simple Reports From A Master Spreadsheet
    By Scott1888 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 05-21-2006, 05:45 AM

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