+ Reply to Thread
Results 1 to 4 of 4

VBA maximum line length and workarounds

  1. #1
    Registered User
    Join Date
    02-16-2012
    Location
    Utah
    MS-Off Ver
    Excel 2007
    Posts
    4

    VBA maximum line length and workarounds

    Hello all,

    I have an extremely long (1440 characters) formula that I'm trying to add to a VBA script to paste into a range of cells. The formula itself works fine in a spreadsheet, and the VBA script to select my cell range and paste into the cells also works fine. The problem is that whenever I try to paste my formula into my script, I get an error.

    It would seem that there is a maximum character length to lines in VBA, which is too low to accomodate my whole formula. Can someone please confirm if that is the case and if so are there any workarounds?

    I considered breaking the formula apart into text strings, pasting them into empty cells, then concatenating the contents of the cell back into a single string and pasting that string into my range of cells, but I couldn't make that work either. And of course it would be nice if I didn't have to go that route.

    Here is my VBA script:
    Please Login or Register  to view this content.
    And here is my unwieldy formula formatted with double quotation marks for pasting into my script:
    Please Login or Register  to view this content.
    The formula itself is basically irrelevant because it works fine on its own. Only the length of it seems to be significant.

    Thanks in advance.

  2. #2
    Forum Expert JapanDave's Avatar
    Join Date
    06-10-2008
    Location
    The grid, I got in!
    MS-Off Ver
    Excel 2010/13
    Posts
    1,696

    Re: VBA maximum line length and workarounds

    I guess to first question to ask is if what you are after can be done within some VBA code without the formula.(That is one beast of a formula) At the risk of be wrong, I have not seen many instances where some code could not achieve the same result. Maybe posting a dummy book and a brief explanation of what your trying to do and then see if this could be done with some code?
    Be fore warned, I regularly post drunk. So don't take offence (too much) to what I say.
    I am the real 'Napster'
    The Grid. A digital frontier. I tried to picture clusters of information as they moved through the computer. What did they look like? Ships? motorcycles? Were the circuits like freeways? I kept dreaming of a world I thought I'd never see. And then, one day...

    If you receive help please give thanks. Click the * in the bottom left hand corner.

    snb's VBA Help Files

  3. #3
    Registered User
    Join Date
    02-16-2012
    Location
    Utah
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: VBA maximum line length and workarounds

    As a work around for now I split the formula up into several operations and used the script to paste these smaller chunks into several columns and then concatenated the results to get the output I wanted. But it means I have a bunch of junk columns for the intermediate steps.

    I'm sure there's a way to do what I want in script, and I'm also sure there's a much shorter way to have done my formula to get the same result. But for now it works I suppose.

    When I get a moment I will paste a dummy book to show what I'm trying to do. Thanks.

  4. #4
    Forum Expert JapanDave's Avatar
    Join Date
    06-10-2008
    Location
    The grid, I got in!
    MS-Off Ver
    Excel 2010/13
    Posts
    1,696

    Re: VBA maximum line length and workarounds

    No problem. I look forward to a challenge!

+ 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