+ Reply to Thread
Results 1 to 8 of 8

Formula in VBA -- formula is too long

  1. #1
    Forum Contributor
    Join Date
    02-05-2014
    Location
    Bay Area
    MS-Off Ver
    Excel 2010
    Posts
    164

    Formula in VBA -- formula is too long

    Evening -
    I closed an earlier post where I don't believe I explained myself clearly, and I believe my post was in the wrong section. Apologies for the confusion.

    I'm having a heck of a time finding a simple solution to my problem.

    Problem:
    In the attached sample workbook, starting with cell E2 I would like to show a list of the unique values shown in columns A,B,C and D. I plan to record this formula into a VBA/macro, and while the current array formula that I'm using works outside of VBA, it is too long for VBA (e.g., VBA has an array character limit of 255).

    Any clever solutions?

    Thanks for the help!
    Attached Files Attached Files

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

    Re: Formula in VBA -- formula is too long

    Do you want to stick with formula?
    Else
    Please Login or Register  to view this content.
    Edit: found a typo was a(i,1)
    And the data range should be changed as fixed above.
    Last edited by jindon; 08-31-2016 at 11:35 PM.

  3. #3
    Forum Expert
    Join Date
    08-02-2013
    Location
    Québec
    MS-Off Ver
    Excel 2003, 2007, 2013
    Posts
    1,414

    Re: Formula in VBA -- formula is too long

    Hello macrorookie,

    I was working on a solution similar to the one posted by Jindon...
    Posting it anyway..

    Please Login or Register  to view this content.
    GC Excel

    If this post helps, then click the star icon (*) in the bottom left-hand corner of my post to Add reputation.

  4. #4
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,892

    Re: Formula in VBA -- formula is too long

    I know that the solutions provided is excellent and perfect
    Here's my try splitting the array formula to two parts to avoid the error

    Please Login or Register  to view this content.
    < ----- Please click the little star * next to add reputation if my post helps you
    Visit Forum : From Here

  5. #5
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,892

    Re: Formula in VBA -- formula is too long

    @Mr. Jindon
    I think the code need to be revised as the count of unique items in Column A:D is 45 not 44 ... so Columns("a:b") to be a:d
    And the whole number of items is 244 while is your 238 ... so
    Please Login or Register  to view this content.
    would be
    Please Login or Register  to view this content.
    Last edited by YasserKhalil; 09-01-2016 at 03:22 AM.

  6. #6
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Formula in VBA -- formula is too long

    YasserKhalil,
    That was my initial thought of splitting the code in to parts, but Jerry came up with a great alternative of using "Named Range"

    Link

    http://www.excelforum.com/excel-prog...y-formula.html

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

    Re: Formula in VBA -- formula is too long

    Yeah, I missed that
    Please Login or Register  to view this content.

  8. #8
    Forum Contributor
    Join Date
    02-05-2014
    Location
    Bay Area
    MS-Off Ver
    Excel 2010
    Posts
    164

    Re: Formula in VBA -- formula is too long

    Outstanding solution, gang. Thanks so much for the help. All of the solutions worked exactly as I need to them to work, and I learned a few things through your various ideas.
    Much appreciated!!

+ 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. compress a long formula to a shorter formula
    By andy_tap in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 06-21-2016, 02:01 AM
  2. Formula too long for Formula.Array
    By Jose Gregorio in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-08-2016, 11:19 PM
  3. Shortening of long array formula by short formula
    By paradise2sr in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 10-29-2013, 05:51 AM
  4. My Formula too long. It is an epic Formula though
    By R0113 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 08-28-2013, 02:45 AM
  5. Formula to long
    By pdmkh in forum Excel General
    Replies: 5
    Last Post: 07-22-2011, 11:55 AM
  6. Long long formula not calc'ing all steps
    By jvautour in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 10-01-2009, 10:26 AM
  7. Formula Too Long
    By iritchie in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 04-18-2008, 10: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