+ Reply to Thread
Results 1 to 8 of 8

putting a function into VB code

  1. #1
    Registered User
    Join Date
    10-03-2015
    Location
    New York
    MS-Off Ver
    Excel 2010
    Posts
    6

    putting a function into VB code

    I have looked at other boards but I cannot seem to figure out how to put a function into VB code and have it work correctly

    I am trying to put this formula into VB:
    =INDEX('Data'!$G:$G,MATCH($C$6,'Data'!$C:$C,0)+4)

    Following some other pages I have tried to use this:
    Please Login or Register  to view this content.
    Thanks in advanced for your help
    Last edited by Pontiac; 10-05-2015 at 04:41 PM.

  2. #2
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,660

    Re: putting a function into VB code

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here



    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)

  3. #3
    Registered User
    Join Date
    10-03-2015
    Location
    New York
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: putting a function into VB code

    fixed the post error

  4. #4
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,660

    Re: putting a function into VB code

    Here, try this:

    Please Login or Register  to view this content.
    And please don't delete your question today.
    It's not polite.

  5. #5
    Registered User
    Join Date
    10-03-2015
    Location
    New York
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: putting a function into VB code

    I just get the same error that says invalid outside procedure

  6. #6
    Valued Forum Contributor
    Join Date
    08-07-2014
    Location
    Quito, Ecuador
    MS-Off Ver
    Excel 2016 & 365, Windows 10
    Posts
    511

    Re: putting a function into VB code

    Pontiac

    When I need to evluate formulas in VBA I use this type of writing:

    Please Login or Register  to view this content.
    and usually it works well

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

    Re: putting a function into VB code

    The Name (string) argument of the Evaluate function doesn't start with an equal sign. Try this:

    Please Login or Register  to view this content.
    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

  8. #8
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: putting a function into VB code

    How about

    Please Login or Register  to view this content.
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

+ 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. [SOLVED] Need help putting together a nested IF function with AND/OR ??
    By TerryBogard in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 06-22-2015, 08:08 PM
  2. Function in VBA and putting it into excel
    By lucya67 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 04-01-2015, 03:58 AM
  3. VBA coding for putting VLookup function
    By aravindkm in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-17-2014, 03:16 AM
  4. Putting Code To A Button In Excel / VB
    By Rapid in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 04-16-2013, 12:04 PM
  5. Replies: 10
    Last Post: 12-16-2011, 12:41 PM
  6. Putting Input box into existing code
    By jpthelpguy in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-23-2009, 02:14 AM
  7. Putting UDF in custom or predefined function category
    By ExcelMonkey in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 03-06-2006, 04:55 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