Results 1 to 2 of 2

Extract a column from an Array VBA

Threaded View

  1. #1
    Forum Contributor
    Join Date
    07-30-2013
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    476

    Extract a column from an Array VBA

    What's the most optimal way to pull a column from an array.

    Right now I'm looping, but this seems opposite of smart. Is there a way I can use Application.Index or something else to get it in one go?

    for instance in Worksheet I can write: Index(Array, , Column) or Index(Array, row,) to get the entire column or row respectively

    I've tried MyLSAC = Application.Index(Testing, 0, 3) ...............to no avail, any help would be much appreciated

    Current Code below

    Sub LSACFill()
    
    TestsTaken = Sheet3.Cells(6, 1).End(xlDown)
    Distance = Sheet3.Cells(1, 1).End(xlDown).Row
    
    TStart = Val(Sheet5.TestsStart)
    TEnd = Val(Sheet5.TestsEnd)
    n = TestsTaken - TStart
    m = TEnd - TStart
    
    Dim Testing As Variant
    
    
    Dim MyLSAC() As Variant
    Dim LSACSelec() As Long
    
    ReDim LSACSelec(0)
    
    Testing = Sheet3.Cells(7, 3).Resize(TestsTaken, 1)
    
    
    
    c = 0
    For i = 1 To TestsTaken
        MyLSAC(c) = Testing(i, 3)
        c = c + 1
    Next
    
    
    c = 0
    For i = 0 To m
        If Sheet5.TESTS.Selected(i) Then
            ReDim Preserve LSACSelec(c)
            LSACSelec(c) = MyLSAC(i)
            c = c + 1
        End If
    Next
    
    Sheet5.LSAC.List = LSACSelec
    
    End Sub
    Last edited by cmore; 10-14-2013 at 02:57 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] What is wrong with this code? (Extract Row from 2D array to 1D array)
    By mc84excel in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-10-2013, 07:17 AM
  2. [SOLVED] Array formula to extract data
    By lstevenson in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 12-12-2012, 07:30 PM
  3. [SOLVED] Extract data after a 16-char array
    By Zaeguzah in forum Excel General
    Replies: 1
    Last Post: 10-07-2012, 01:18 PM
  4. extract an array from a string
    By mark@mrc in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-18-2011, 04:31 PM
  5. How to extract one field from within a multidimensional array?
    By imaraq in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 07-14-2009, 12:40 PM

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