+ Reply to Thread
Results 1 to 3 of 3

Can you use Dynamic Variables in UDFs?

  1. #1
    Forum Contributor
    Join Date
    01-25-2011
    Location
    Virginia
    MS-Off Ver
    Excel 2016
    Posts
    166

    Can you use Dynamic Variables in UDFs?

    I am trying to use dynamic variables in UDFs simular to the CountIfs function which assumes only one condition, but as soon as you type in a condition, then a box pops up for a second condition and so on.

    My code looks like
    Please Login or Register  to view this content.
    The first line won't compile, but the rest is fine. I could accept hard coding the first line with logical_test_1, value_if_true_1, logical_test_2, etc. but would still prefer to use the dynamic coding for the function execution.

    Any ideas on how to make this work are appreciated.

    Regards,

    Tom
    Last edited by tom.hogan; 03-17-2011 at 12:00 PM.

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Can you use Dynamic Variables in UDFs?

    You can, although you can only have one and it has to be the last parameter. (If you think about that for a while you'll see why it must be true. Think about how to use COUNTIFS, since you mentioned that as an example.) Are you trying to include a dynamic number of pairs of parameters? The way to do that would be a little more complicated, because you can only include one such array; you can't use two like you tried. We have to reorder your parameter list. You would call it like this:

    Please Login or Register  to view this content.
    Here is the code:
    Please Login or Register  to view this content.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Forum Contributor
    Join Date
    01-25-2011
    Location
    Virginia
    MS-Off Ver
    Excel 2016
    Posts
    166

    Re: Can you use Dynamic Variables in UDFs?

    That works, thank you very much for the help and the explanation.

    Regards,

    Tom

+ 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