Results 1 to 5 of 5

Passing 2-dimensional arrays between subroutines

Threaded View

  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:
    Private Sub CommandButton1_Click()
    Call ReadData
    End Sub
    Module1:
    Option Explicit
    Option Base 1
    Public MyRange, InputArray As Variant
    
    Sub ReadData()
    Set MyRange = Application.InputBox("Mark the data array", Type:=8)
    If Not MyRange Is Nothing Then
    InputArray = MyRange
    End If
    End Sub
    Last edited by AliGW; 07-30-2018 at 01:30 AM. Reason: Withdrawn post reinstated.

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