+ Reply to Thread
Results 1 to 3 of 3

Writing long array formula in VBA?

  1. #1
    Forum Contributor
    Join Date
    10-12-2011
    Location
    Sydney
    MS-Off Ver
    Excel 2016 in 2024
    Posts
    857

    Writing long array formula in VBA?

    Hi,

    I had a problem which was solved over in formulas section. I have this long array formula that I need to put into VBA, but I think it is too long and over the character limit.

    Does anyone know how I can do this in vba?

    =IFERROR(IF(LOOKUP(1E+100,CHOOSE({1,2,3,4},LOOKUP(2,1/((Today!$B3=Summary!$B$4:$B$1000)*(Today!$F3=Summary!$C$4:$C$1000)*OR(Today!$E3={"G","G2","G3","G4","D","D4"})),Summary!$D$4:$D$1000),LOOKUP(2,1/((Today!$B3=Summary!$N$4:$N$1000)*(Today!$F3=Summary!$O$4:$O$1000)*OR(Today!$E3={"D5","S5"})),Summary!$P$4:$P$1000),LOOKUP(2,1/((Today!$B3=Summary!$Z$4:$Z$1000)*(Today!$F3=Summary!$AA$4:$AA$1000)*OR(Today!$E3={"S","Sl6","Sl7","St6"})),Summary!$AB$4:$AB$1000),LOOKUP(2,1/((Today!$B3=Summary!$AL4:$AL$1000)*(Today!$F3=Summary!$AM$4:$AM$1000)*OR(Today!$E3={"H","H8","H9","H10"})),Summary!$AN$4:$AN$1000)))>0.05,Today!$D3,""),"No data")

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

    Re: Writing long array formula in VBA?

    Hi maym,

    Array formulas via VBA have a 255 character limit whereas your formula has 631 characters. You can try the following but as it uses SendKeys it's not really recommended (it won't work if you run it from the Visual Basic Editor either as F2 in that mode opens the Object Browser):

    Please Login or Register  to view this content.
    The above puts the array formula into cell E5 of the active sheet. Change to suit.

    Regards,

    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 Contributor
    Join Date
    10-12-2011
    Location
    Sydney
    MS-Off Ver
    Excel 2016 in 2024
    Posts
    857

    Re: Writing long array formula in VBA?

    Hi Trebor, thanks. I thought the 255 character limit might have been affecting it. I will try yours and see how I go!

+ 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. Writing an Array Formula in VBA
    By jwongsf in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-28-2016, 05:20 PM
  2. [SOLVED] Writing Array back to worksheet takes long :-(
    By CostCare in forum Excel Programming / VBA / Macros
    Replies: 28
    Last Post: 11-12-2015, 05:02 AM
  3. [SOLVED] Long Formula Array
    By henxan in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-04-2014, 09:03 AM
  4. Help needed for creating array and writing formula in VBA, code included
    By yanheng in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-14-2012, 02:00 PM
  5. Long Array Formula VBA
    By maacmaac in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-27-2011, 08:57 AM
  6. writing formula in range on each sheet via array
    By Armitage2k in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-20-2011, 12:59 PM
  7. [SOLVED] Syntax for Writing Long VBA Formula on Multiple Lines
    By nwd9s in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-13-2011, 06:38 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