Closed Thread
Results 1 to 5 of 5

Evaluate() an array

Hybrid View

  1. #1
    Registered User
    Join Date
    08-29-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2010
    Posts
    10

    Evaluate() an array

    I've created dynamic formulas in excel. Unfortunately, it creates the formula as a string. To get around this I created a function (Evalu) that using the Evaluate() function to give me the answer. This currently works fine.

    However, the problem I now is how to apply this to an array. My formula currently evaluates to
    =evaluS({"100*100+0";"50*10+0";"0*0+0"})
    before it breaks. I'm trying to get to the result of 10500 by adding each array element together. Notice that each element in the array is a string, that I want to get evaluated as a formula.

    To do this, I create the evaluS function:

    Function EvaluS(S() As String) As String
    Dim i As Long
    Dim A As Integer
    Dim Arr As String
    
    For i = LBound(S) To UBound(S)
    Arr = S(i)
    A = A + Evaluate(Arr)
    Next
    EvaluS = A
    End Function
    Clearly this approach isn't working very well, and since I'm a VBA expert, I was hoping someone could show me the error of my ways.
    Attached Files Attached Files
    Last edited by blueiris8; 08-29-2012 at 03:03 PM.

  2. #2
    Valued Forum Contributor
    Join Date
    03-16-2012
    Location
    Aarhus, Denmark
    MS-Off Ver
    Excel 2007
    Posts
    992

    Re: Evaluate() an array

    This is a duplicate post; the original post is found here:
    http://www.excelforum.com/excel-prog...-an-array.html
    Sincerely
    S?ren Larsen

    "Give a man a fish, and you'll feed him for a day. Give a man a fishing rod, and he'll steal your yacht!"

  3. #3
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,239

    Re: Evaluate() an array

    Hi,

    Please don't post the same question twice, this is a duplication of http://www.excelforum.com/excel-prog...-an-array.html

    Also, please try not to cross post, if you do, it is considered polite to include a link to where else you have asked the question: http://www.mrexcel.com/forum/excel-q...ate-array.html

  4. #4
    Registered User
    Join Date
    08-29-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: Evaluate() an array

    I was able to solve this with some help:

    Function EvaluS(S())
    Dim i As Long
    For i = LBound(S) To UBound(S)
    EvaluS = EvaluS + Evaluate(S(i))
    Next i
    End Function

  5. #5
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: Evaluate() an array

    Hello blueiris8, and welcome to the forum.

    Unfortunately you have inadvertently broken one of the forum rules. Please read the following. Thanks.

    This is a duplicate post and as such does not comply with Rule 5 of our forum rules. This thread will now be closed, you may continue in your other thread.

    Thread Closed.

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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