Results 1 to 2 of 2

Thread: Transposing arrays to the worksheet

  1. #1
    Senior Member
    Join Date
    Apr 2011
    Posts
    190
    Rep Power
    14

    Transposing arrays to the worksheet

    I am using the code below to move data from a two dimensional array to the worksheet – I would however like to only transpose certain elements within the array – so let’s say the array is 7 by 12 elements - is there a way to only transpose the elements 3,2 to 3,9 (my arrays are option base zero).
    If this cannot be done – what is the best way to create a new array that only contain the elements 3,2 to 3,9 – that way I can still use the .transpose function. My arrays are quite large and I don’t want to use a loop – as it is too slow.

    Code:
    Astr = Split(Cells(1, ColFirst).Address, "$")(1) & LastRow + 1 & ":" & _
                    Split(Cells(1, ColFirst + UBound(Pnames) - 1).Address, "$")(1) & _
                    LastRow + 1 + UBound(WetChem, 2) - 1
    
    
     ActiveSheet.Range(Astr).Value = Application.WorksheetFunction.Transpose(WetChem)

    https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA
    Last edited by DocAElstein; 10-02-2023 at 12:57 PM.
    xl2007 - Windows 7
    xl hates the 255 number

  2. #2
    Administrator Admin's Avatar
    Join Date
    Mar 2011
    Posts
    1,123
    Rep Power
    10
    Hi Rasm,

    You mean something like this

    Code:
    Sub kTest()
        
        Dim Ary1, Ary2
        
        Ary1 = [a1:e10]
        
        'picks data from 2nd,3rd and 4th column of 3rd row from array Ary1
        Ary2 = Application.Index(Ary1, 3, [{2,3,4}]) 'Array(2,3,4)
        
        [g1].Resize(, UBound(Ary2, 1)) = Ary2
        
    End Sub
    Cheers !

    Excel Range to BBCode Table
    Use Social Networking Tools If You Like the Answers !

    Message to Cross Posters

    @ Home - Office 2010/2013/2016 on Win 10 (64 bit); @ Work - Office 2016 on Win 10 (64 bit)

Similar Threads

  1. Filter In Arrays
    By Transformer in forum Tips, Tricks & Downloads (No Questions)
    Replies: 0
    Last Post: 05-28-2013, 08:40 PM
  2. Print Nth Worksheet To Mth Worksheet using VBA
    By Ryan_Bernal in forum Excel Help
    Replies: 2
    Last Post: 02-28-2013, 06:57 PM
  3. Replies: 14
    Last Post: 01-26-2013, 04:58 AM
  4. Create list with arrays
    By PcMax in forum Excel Help
    Replies: 2
    Last Post: 04-10-2012, 11:05 PM
  5. Making a Histogram Chart Using Arrays
    By Rasm in forum Download Center
    Replies: 2
    Last Post: 04-05-2011, 07:22 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •