+ Reply to Thread
Results 1 to 4 of 4

Passing a whole set of values of an array to a function

  1. #1
    Registered User
    Join Date
    11-26-2008
    Location
    Philippines
    Posts
    26

    Passing a whole set of values of an array to a function

    Hello there,

    I am trying to solve a problem of this topic.

    I am assigning the values to an array,

    therefore

    Please Login or Register  to view this content.
    Subsequently, I'd like to pass all the array values to a function.

    I have tried to pass them - the whole set of values - this way

    Please Login or Register  to view this content.
    and then defining the function as

    Please Login or Register  to view this content.
    Then I utilize the values to realize a calculation into the same function.


    When trying to call the function_A, I get the following error

    <<type non correspondent>>

    (and the call arr() is highlighted)

    Please, could anybody kindly explain me the error I am doing and how could I solve this issue ?

    Many thanks
    Last edited by pike; 01-28-2012 at 07:46 AM.

  2. #2
    Valued Forum Contributor Steffen Thomsen's Avatar
    Join Date
    10-15-2010
    Location
    Kolding, Denmark
    MS-Off Ver
    Excel 2007 and Excel 2010
    Posts
    953

    Re: Passing a whole set of values of an array to a function

    Try

    Please Login or Register  to view this content.
    This takes an array into the function

    Example

    Please Login or Register  to view this content.
    Please take time to read the forum rules

  3. #3
    Registered User
    Join Date
    01-14-2008
    Posts
    21

    Re: Passing a whole set of values of an array to a function

    Hello, this is an interesting post.

    Please let me append to this thread to introduce a new variable concerning the thread I was going to write.

    How would it work in case of a two or three dimensional array ?

    The key point is:

    - the function
    Public Function function_A(arr As Variant)

    - the array
    arr = WorksheetFunction.transpose(Sheets(1).Range("A1:A5");Sheets(1).Range("B2:B4"))

    Call function_A(arr).

    How can I pass to the function the second dimension of the array ?

    Thank you very much

  4. #4
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: Passing a whole set of values of an array to a function

    Mr Reds

    Welcome to the Forum, unfortunately:

    Your post does not comply with Rule 2 of our Forum RULES. Don't post a question in the thread of another member -- start your own thread. If you feel it's particularly relevant, provide a link to the other thread. It makes sense to have a new thread for your question because a thread with numerous replies can be off putting & difficult to pick out relevant replies.
    If the solution helped please donate to RSPCA

    Site worth visiting: Rabbitohs

+ 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