+ Reply to Thread
Results 1 to 5 of 5

VBA doesn't work when string length more than 255 characters in the code lines

  1. #1
    Registered User
    Join Date
    10-19-2012
    Location
    Houston, US
    MS-Off Ver
    Excel 2007
    Posts
    46

    VBA doesn't work when string length more than 255 characters in the code lines

    Hello forum,
    I have a work sheet with hundreds of row & column. I use VBA to auto fill in "Yes" for all cells but some cells have to be " No". The VBA has functions to reset all cells or each row to the default. It has been working fine until the string length in the VBA get more than 255 characters when I add more cells to the VBA (screen shot 1 &2). How can I increase this number (could be more than 1,000) so it can cover more cells.
    The goal is to make the yellow highlight cells in column AG changed to "No" when the user resets the rows 67, 68, 70 & so on or reset all
    Thank you for your help.
    Thup_98

    Please Login or Register  to view this content.
    Attached Images Attached Images
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: VBA doesn't work when string length more than 255 characters in the code lines

    why must you do it all in one line....?
    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

  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,605

    Re: VBA doesn't work when string length more than 255 characters in the code lines

    Easiest way would be to change the If ... Then ... to an If ... Then ... End If and split the Me.Range into two or three parts. Or use underscore (_) to split the line.
    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
    10-19-2012
    Location
    Houston, US
    MS-Off Ver
    Excel 2007
    Posts
    46

    Re: VBA doesn't work when string length more than 255 characters in the code lines

    Thank you humdingaling & TMS. It works perfectly
    Thup_98

  5. #5
    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,605

    Re: VBA doesn't work when string length more than 255 characters in the code lines

    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. [SOLVED] Add string as formula through code doesn't work with sumif
    By vizzkid in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-23-2016, 10:04 AM
  2. Replies: 7
    Last Post: 12-17-2015, 05:14 PM
  3. [SOLVED] Shorten string length if exceeds 31 characters (max sheet name length)
    By r2fro in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-03-2014, 05:57 AM
  4. [SOLVED] My code to find longest string in column doesn't work properly! Need Help!!
    By refree in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-03-2013, 08:27 AM
  5. Replies: 7
    Last Post: 10-23-2012, 08:38 AM
  6. [SOLVED] Complicated Macro doesn't work properly if lines are deleted
    By BuzzOffSweetheart in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 07-11-2012, 01:32 PM
  7. [SOLVED] How can I control the length of characters a code will return?
    By Tayo in forum Excel General
    Replies: 0
    Last Post: 04-07-2006, 11:25 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