+ Reply to Thread
Results 1 to 5 of 5

Passing 2-dimensional arrays between subroutines

  1. #1
    Registered User
    Join Date
    07-29-2018
    Location
    In the Queen's Shed
    MS-Off Ver
    2013
    Posts
    23

    Question Passing 2-dimensional arrays between subroutines

    I cannot seem to get this to work.

    I want to pass a 2D-array from a subroutine to other subroutines in which a data manipulation should take place.

    I am calling below subroutine from a command button on Sheet1. In Module1 I have declared the variables as public. Inside the subroutine ReadData, at the End If statement, InputArray is populated with an array consisting of numbers that the user has marked following the inputbox. After the subroutine ReadData has completed, InputArray is empty.

    What is the obvious and blatantly daft thing that am I doing wrong?

    Sheet1:
    Please Login or Register  to view this content.
    Module1:
    Please Login or Register  to view this content.
    Last edited by AliGW; 07-30-2018 at 01:30 AM. Reason: Withdrawn post reinstated.

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Passing 2-dimensional arrays between subroutines

    Your code worked for me without any changes. InputArray was populated after the procedure ended.

    I might change this just to avoid ambiguity.

    Please Login or Register  to view this content.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Passing 2-dimensional arrays between subroutines

    edit:- Code tags added to post #1 moderation request removed.
    Last edited by jason.b75; 07-30-2018 at 02:32 AM.

  4. #4
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,780

    Re: Passing 2-dimensional arrays between subroutines

    Rule 08: Cross-posting Without Telling Us

    Your post does not comply with Rule 8 of our Forum RULES. Do not cross-post your question on multiple forums without telling us about your threads on other forums.

    Post a link to any other forums where you have asked the same question. If you have fewer than 10 posts here, you will not be able to post a link, but you must still tell us where else you have asked the question.

    Cross-posting is when you post the same question in other forums on the web. The last thing you want to do is waste people's time working on an issue you have already resolved elsewhere. We prefer that you not cross-post at all, but if you do (and it's unlikely to go unnoticed), you MUST provide a link (copy the url from the address bar in your browser) to the cross-post.

    Expect cross-posted questions without a link to be closed and a message will be posted by the moderator explaining why. We are here to help so help us to help you!

    Read this to understand why we ask you to do this, and then please edit your first post to include links to any and all cross-posts in any other forums (not just this site).

    If you have less than 10 posts, do not try to copy and paste the link. Instead, type the link out in your thread.

    No further help to be offered, please, until the OP has complied with this request.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  5. #5
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,780

    Re: Passing 2-dimensional arrays between subroutines

    @ Pak - do not post-edit your posts, as it renders the thread meaningless and useless to anyone looking for help with a similar issue. Do not do this again.

    What you were asked to do is provide cross-post links. We are still waiting for you to provide these. Once you have done so, you may receive further help if you need it.
    Last edited by AliGW; 07-30-2018 at 04:02 AM.

+ 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. Passing variables back and forth between subroutines
    By beachbum2015 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-12-2015, 11:50 AM
  2. Declaring multiple multi-dimensional arrays (jagged arrays) - compile error?
    By dfribush in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 12-20-2013, 05:06 PM
  3. [SOLVED] New to arrays-where do I find a good beginners guide to multi dimensional arrays
    By mc84excel in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 06-04-2013, 07:44 PM
  4. Passing 2 Dimensional Arrays to functions
    By keithabailey in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 09-23-2011, 05:28 AM
  5. Passing Multi-Dimensional Arrays
    By dldecler in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 03-28-2011, 02:03 PM
  6. Passing Variables out of Subroutines
    By cmcconnehey in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-24-2007, 08:20 PM
  7. Calling subroutines and passing variables
    By matpj in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-29-2006, 11:25 AM

Tags for this Thread

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