+ Reply to Thread
Results 1 to 11 of 11

concatenate result into a formula?

  1. #1
    Registered User
    Join Date
    10-24-2012
    Location
    IL, USA
    MS-Off Ver
    Excel 2007
    Posts
    26

    concatenate result into a formula?

    I have a concatenate function in cell B21 that yeilds "Average(sheetabc! B130:2000)"

    Currently, I want to analyze that result in cell B24, but I have to copy B21 and paste special values into cell B24 and then add an equals sign.

    My question: Is there any way to just have B24 be "=B21" so it will automatically do it and I can avoid the time consuming copy, paste values, add equals sign routine?

    Thanks
    Last edited by HDeuce; 03-13-2013 at 11:32 PM.

  2. #2
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,735

    Re: concatenate result into a formula?

    There is an Evaluate function in VBA for doing this, but you can't call this directly from a worksheet cell. Instead, you need to set up a small User-Defined Function (UDF), like this:

    Please Login or Register  to view this content.
    and then you can use it like this:

    =Eval(B21)

    Hope this helps.

    Pete

  3. #3
    Registered User
    Join Date
    10-24-2012
    Location
    IL, USA
    MS-Off Ver
    Excel 2007
    Posts
    26

    Re: concatenate result into a formula?

    Quote Originally Posted by Pete_UK View Post
    There is an Evaluate function in VBA for doing this, but you can't call this directly from a worksheet cell. Instead, you need to set up a small User-Defined Function (UDF), like this:

    Please Login or Register  to view this content.
    and then you can use it like this:

    =Eval(B21)

    Hope this helps.

    Pete
    Thank you for the suggestion. I tried it but I get a "#NAME?" error as a result.
    Last edited by HDeuce; 03-13-2013 at 11:41 AM.

  4. #4
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,735

    Re: concatenate result into a formula?

    Did you copy the UDF into a standard Module in the Visual Basic Editor? Did you choose Enable Macros when first opening the file?

    Pete

  5. #5
    Registered User
    Join Date
    10-24-2012
    Location
    IL, USA
    MS-Off Ver
    Excel 2007
    Posts
    26

    Re: concatenate result into a formula?

    Yes. I am unfamiliar with Visual Basic, but I did do Alt F11 and enter it in and save. The file was originally a .xls, but I xid a save as .xlsm. I tried to reopen the file and enable content but I get the same error.

    In B21 the text is "average(......." and I have tried "=average(......" but nothing seems to help.

  6. #6
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,735

    Re: concatenate result into a formula?

    Well, there is only so much I can do from a distance and without seeing your workbook - perhaps you can attach your file (the FAQ describes how to).

    Hope this helps.

    Pete

  7. #7
    Registered User
    Join Date
    10-24-2012
    Location
    IL, USA
    MS-Off Ver
    Excel 2007
    Posts
    26

    Re: concatenate result into a formula?

    I will make a dummy file (eliminate important data) and post. Thanks for the help.

  8. #8
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,829

    Re: concatenate result into a formula?

    Could it be a conflict in names between the eval function http://msdn.microsoft.com/en-us/libr...ice.10%29.aspx and the evaluate method http://msdn.microsoft.com/en-us/libr...ice.12%29.aspx ? At this point, I might try some different names and make sure I understood the difference between the eval() function and the evaluate method.
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  9. #9
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: concatenate result into a formula?

    the evaluate function already exists as excel4.0 and can be used in a named formula

    insert name /define create name eg hdeuce
    in refers to put
    =evaluate(Sheet1!$b$21)
    in b24 put =hdeuce
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  10. #10
    Registered User
    Join Date
    10-24-2012
    Location
    IL, USA
    MS-Off Ver
    Excel 2007
    Posts
    26

    Re: SOLVED concatenate result into a formula?

    Quote Originally Posted by Pete_UK View Post
    Well, there is only so much I can do from a distance and without seeing your workbook - perhaps you can attach your file (the FAQ describes how to).

    Hope this helps.

    Pete
    Pete, as I was saving the dummy file it wouldn't work. I went back in to check soemthing and it worked. I have no idea why. I did hit enable macros every time. Either way it works. Thank you so much for the help.
    Last edited by HDeuce; 03-13-2013 at 11:31 PM. Reason: SOLVED

  11. #11
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,735

    Re: SOLVED concatenate result into a formula?

    Glad to hear that you got it working - thanks for feeding back.

    Pete

+ 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