+ Reply to Thread
Results 1 to 9 of 9

Is their a maximum number of ranges in code

  1. #1
    Registered User
    Join Date
    09-09-2018
    Location
    Vancouver, canada
    MS-Off Ver
    2010
    Posts
    76

    Is their a maximum number of ranges in code

    I have code that works except when the line “For Each pair In Range("B30, F30, J30") gets to many ranges put in it. I can put in around 30 or 35 then the code just stops working. Is their a maximum number of ranges or how can I solve this problem?

    I have researched this but can only find line-continuation character but that solve the problem.


    Please Login or Register  to view this content.
    Thanks so much.

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Is their a maximum number of ranges in code

    The limit for a range string is 255 characters.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,474

    Re: Is their a maximum number of ranges in code

    Something to play with ...

    Please Login or Register  to view this content.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  4. #4
    Registered User
    Join Date
    09-09-2018
    Location
    Vancouver, canada
    MS-Off Ver
    2010
    Posts
    76

    Re: Is their a maximum number of ranges in code

    Hi TMS

    Thank-you so much for your reply. I'm not anyway as knowledgeable as you but if I'm correct the code has to changed to accept up to 100 ranges (your change) am I correct in this? I have a family get together on Sunday and so I can't test this until Monday if that's okay. Hope you have a wonderful weekend.
    Scott

  5. #5
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,535

    Re: Is their a maximum number of ranges in code

    Quote Originally Posted by scott1945 View Post
    I have code that works except when the line “For Each pair In Range("B30, F30, J30") gets to many ranges put in it. I can put in around 30 or 35 then the code just stops working. Is their a maximum number of ranges or how can I solve this problem?
    You can still write something like
    Please Login or Register  to view this content.

  6. #6
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,474

    Re: Is their a maximum number of ranges in code

    Yes. In this case, it is simply generating a union of 100 addresses. But you could use an array of addresses. It's just the length of the string that is limited.

    Enjoy your family get together

  7. #7
    Registered User
    Join Date
    09-09-2018
    Location
    Vancouver, canada
    MS-Off Ver
    2010
    Posts
    76

    Re: Is their a maximum number of ranges in code

    Hi jindon

    Thank-you so much for your reply. Tried your suggestion and it works great.

  8. #8
    Registered User
    Join Date
    09-09-2018
    Location
    Vancouver, canada
    MS-Off Ver
    2010
    Posts
    76

    Re: Is their a maximum number of ranges in code

    Hi TMS

    I tried your suggestion as well and got it to work. Thank-you both so much for all your help. It can be really hard to find these solutions. Have a great day.
    Scott

  9. #9
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,474

    Re: Is their a maximum number of ranges in code

    You're welcome. Thanks for the rep.

+ 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. Maximum Value in Different and Variable Ranges
    By yorgosnc in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-09-2015, 09:14 AM
  2. Maximum number of ranges in an Excel 2010 line graph?
    By Carrfamily in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 03-31-2015, 04:47 PM
  3. [SOLVED] VBA Code To Return The Number Of Columns Between Two Dynamic Ranges.
    By GEANZ in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-04-2013, 01:44 AM
  4. Replies: 1
    Last Post: 10-07-2012, 09:56 PM
  5. Compare a value to a number of ranges and choose the maximum
    By Basq8 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-08-2011, 04:43 AM
  6. Lookup in various ranges, return maximum value
    By adammj58 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-15-2008, 04:44 PM
  7. [SOLVED] Maximum number of Name ranges
    By Jim at Eagle in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-15-2005, 03:07 AM

Tags for this Thread

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