+ Reply to Thread
Results 1 to 4 of 4

Function requires range as a parameter, how to call from VBA ?

  1. #1
    Registered User
    Join Date
    01-08-2012
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    2

    Function requires range as a parameter, how to call from VBA ?

    Hi all,

    A function of an Add-In wants a range as parameter.
    In a worksheet it would look like this: =MyFunction(A1;A2;D10:D11)

    Im calling this from MS Access and do not know how i can assign that virtual D10:D11 to a variable, the "cells" are a date and a number.....

    Thx
    Z

  2. #2
    Forum Expert OnErrorGoto0's Avatar
    Join Date
    12-30-2011
    Location
    I DO NOT POST HERE ANYMORE
    MS-Off Ver
    I DO NOT POST HERE ANYMORE
    Posts
    1,655

    Re: Function requires range as a parameter, how to call from VBA ?

    If it is an Excel add-in, how are you using it in Access? If it is by automating Excel, then you can pass a range from there; if you are not using Excel at all, then you cannot pass it a range. Are you sure it needs a range, and cannot take an array for example?
    Good luck.

  3. #3
    Registered User
    Join Date
    01-08-2012
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re: Function requires range as a parameter, how to call from VBA ?

    Quote Originally Posted by OnErrorGoto0 View Post
    If it is an Excel add-in, how are you using it in Access? If it is by automating Excel, then you can pass a range from there; if you are not using Excel at all, then you cannot pass it a range. Are you sure it needs a range, and cannot take an array for example?
    Yes, im calling it via Excel, i.e.

    ReturnValue = objXL.Run ("MyFunction", a, b, c)

    where objXL is defined as Excel Application.




    ps: Actually the description says it would take an array, but i assumed they mean cells, not an VBA array, but tbh i have little experience with arrays in VBA.
    Last edited by Zaz; 01-08-2012 at 07:48 AM.

  4. #4
    Forum Expert OnErrorGoto0's Avatar
    Join Date
    12-30-2011
    Location
    I DO NOT POST HERE ANYMORE
    MS-Off Ver
    I DO NOT POST HERE ANYMORE
    Posts
    1,655

    Re: Function requires range as a parameter, how to call from VBA ?

    Well if your data is, or can be put, in a range, then you can pass that. If not, I would suggest passing an array to see if it works.

+ 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