+ Reply to Thread
Results 1 to 4 of 4

I need to put a 3 column sheet into an array

  1. #1
    Registered User
    Join Date
    01-19-2018
    Location
    Michigan, USA
    MS-Off Ver
    2016
    Posts
    9

    I need to put a 3 column sheet into an array

    I have searched through everything I can find and am not really getting anywhere. I have a 3 column sheet with a dynamic named range spanning column A. I have tried this

    Please Login or Register  to view this content.
    and it works to a point. The problem is that the number of rows changes. I have tried this

    Please Login or Register  to view this content.
    Which failed because variable LastRow was not allowed in the Array declaration.

    Any ideas?

  2. #2
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    11,541

    Re: I need to put a 3 column sheet into an array

    Option1 (if the "mysheetrange" is a dynamic range)
    Dim MyArr as Variant
    MyArr=Range("MySheetRange").Value
    Option 2,
    do not DIM MyArr, just use:
    ReDim MyArr(1 To Range("mysheetrange").Rows.Count, 1 To Range("Mysheetrange").Columns.Count)
    Last edited by protonLeah; 06-04-2018 at 06:12 PM.
    Ben Van Johnson

  3. #3
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    2007
    Posts
    3,381

    Re: I need to put a 3 column sheet into an array

    Hi there,

    You need to use ReDim:

    Please Login or Register  to view this content.
    Note I've also changed your integer variables to long as their maximum is 32,767 whereas each Excel tab has 1,048,576 rows.

    Regards,

    Robert
    ____________________________________________
    Please ensure you mark your thread as Solved once it is. Click here to see how
    If this post helps, please don't forget to say thanks by clicking the star icon in the bottom left-hand corner of my post

  4. #4
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2013
    Posts
    3,756

    Re: I need to put a 3 column sheet into an array

    Hi there,

    See if the following code does what you need:

    Please Login or Register  to view this content.

    Hope this helps - please let me know how you get on.

    Regards,

    Greg M

+ 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. Replies: 3
    Last Post: 03-07-2016, 09:54 PM
  2. VBA Change colour of row if content in column matches array in another sheet
    By Declamatory in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-07-2015, 06:02 AM
  3. [SOLVED] 2 Column Lookup with 6 Column array Col index number is Varies Within Entire Array
    By Weasyb in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 08-05-2015, 12:54 PM
  4. VBA UserForm - Contact sheet; Using a ComboBox array to write data to specific column
    By willmason in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-01-2014, 09:44 AM
  5. [SOLVED] New to arrays-Create two column array with different column order to sheet?
    By mc84excel in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-02-2013, 01:37 AM
  6. Replies: 2
    Last Post: 06-02-2009, 07:21 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