+ Reply to Thread
Results 1 to 7 of 7

Transpose a table's first row into an array

  1. #1
    Forum Contributor jimmalk's Avatar
    Join Date
    08-31-2012
    Location
    Chicago
    MS-Off Ver
    Excel 2010
    Posts
    113

    Transpose a table's first row into an array

    Good evening. A simple "difficult" question. I wish to transpose the header row of a table into an array.
    Please Login or Register  to view this content.
    The ActiveCell is on a table that's on the worksheet. This code is for the initialization of a form I open. Please help!!
    Last edited by jimmalk; 11-23-2012 at 01:50 AM.

  2. #2
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,376

    Re: Transpose a table's first row into an array

    Hi Jimmalk
    just as an example
    Please Login or Register  to view this content.

  3. #3
    Forum Contributor jimmalk's Avatar
    Join Date
    08-31-2012
    Location
    Chicago
    MS-Off Ver
    Excel 2010
    Posts
    113

    Re: Transpose a table's first row into an array

    Hi Nilem. Thanks very much for your idea. The worksheet has only one table (~900 columns) and the activecell will always be on that table. Is there a simpler way to get the header row into the array? Another (probably stupid) question. Is "Dim RefTabHeader() as string" needed to make it an array?
    Last edited by jimmalk; 11-23-2012 at 02:19 AM.

  4. #4
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,376

    Re: Transpose a table's first row into an array

    ok
    Please Login or Register  to view this content.

  5. #5
    Forum Contributor jimmalk's Avatar
    Join Date
    08-31-2012
    Location
    Chicago
    MS-Off Ver
    Excel 2010
    Posts
    113

    Re: Transpose a table's first row into an array

    Yes, that looks great Nilem. Just 2 questions. Does RefTabHeader need to be declared as "Dim RefTabHeader() As String"? And why a 2-dimentional array if there's only one row to transpose?

  6. #6
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,376

    Re: Transpose a table's first row into an array

    should be so Dim RefTabHeader As Variant (not As String)
    For example
    Please Login or Register  to view this content.
    Upper bound of the first dimension of the arr is equal to 1 (one row), and the upper bound of the second dimension is 4 (4 columns)

  7. #7
    Forum Contributor jimmalk's Avatar
    Join Date
    08-31-2012
    Location
    Chicago
    MS-Off Ver
    Excel 2010
    Posts
    113

    Re: Transpose a table's first row into an array

    I had thought the correct syntax was
    Please Login or Register  to view this content.
    and I used "String" because the header has strings. I also didnt know it was ok to Dim an array variable without the (). Guess that's why everything I had tried was failing. haha If I understand what you wrote about the array dimensions, one dimension is for the row, and the other for column, so an array used for a table row will always be 2 dimensions. Great. Thanks very much Nilem

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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