+ Reply to Thread
Results 1 to 10 of 10

Transfer Array data to Spreadsheet

  1. #1
    Registered User
    Join Date
    06-10-2008
    Posts
    14

    Transfer Array data to Spreadsheet

    Hi Guys,

    I'm trying to transfer information I have held in a table format into a database format.

    I'm using array variables to hold the table data and now I'm trying to use this data held within the array to produce a database.

    For example:

    A 1 2
    B 2 3
    C 3 4

    into

    A1
    A2
    B2
    B3
    C3
    C4

    My code would look like this:
    Please Login or Register  to view this content.
    Where MyArray(1,1) = "A" and MyArray(3,3) = "4"

    What I want to do is refer to one "column" of data within the array so that it will return for column A (or array position 1):

    A
    B
    C

    I can use a loop to do this for me but I was wondering whether there was a solution which would be a little neater?

    This doesn't work but something like:

    Please Login or Register  to view this content.
    Thanks for any help.

  2. #2
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Transfer Array data to Spreadsheet

    [removed - misinterpeted, Kris has posted a solution specific to the question]
    Last edited by DonkeyOte; 08-05-2009 at 06:32 AM.

  3. #3
    Forum Contributor
    Join Date
    02-19-2005
    Location
    Gurgaon,India
    MS-Off Ver
    2007,2010,2013
    Posts
    180

    Re: Transfer Array data to Spreadsheet

    Please Login or Register  to view this content.
    Kris

  4. #4
    Registered User
    Join Date
    06-10-2008
    Posts
    14

    Re: Transfer Array data to Spreadsheet

    Thank you for the response.
    The index gives me the number of "rows" in the array.

    My actual code looks like this:

    Please Login or Register  to view this content.
    This now holds all of the range in the array.
    I now want to go to another spreadsheet and just off load "columns" of the data into the worksheet.

    Please Login or Register  to view this content.
    This will now unload the data in the array which relates to "Column" 1 in the source data to column A in a fresh spreadsheet.

    What I want to see is if I can unload this data without using this loop above in order to save run time as this is taking a long time with the amount of data that I have.

    I thought you might be able to get the array to dump all data relating to a certain dimension into a spreadsheet?

  5. #5
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Transfer Array data to Spreadsheet

    I don't really understand what you want to do and if in fact if Kris' approach (which does what you initially requested) is what you want or not ?

    The INDEX I suggested was based on the fact that I had no clue as to what you were trying to achieve, I merely encased within the COUNTA to show that you could work with all values from one vector in that manner, eg:

    Please Login or Register  to view this content.
    would return the second column of array to A1:Ax on Sheet2 etc... but I'm not sure this is what you want to do ...

  6. #6
    Forum Contributor
    Join Date
    02-23-2006
    Location
    Near London, England
    MS-Off Ver
    Office 2003
    Posts
    770

    Re: Transfer Array data to Spreadsheet

    Do you mean something like this?

    This code shows how you can extract a complete column or row of data from an Array onto a worksheet.

    Please Login or Register  to view this content.
    Test Data in cells A1:C4 (avoided using letters and numbers as test data as that just confuses the issue! )
    Please Login or Register  to view this content.
    If you find the response helpful please click the scales in the blue bar above and rate it
    If you don't like the response, don't bother with the scales, they are not for you

  7. #7
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Transfer Array data to Spreadsheet

    Guys, just for ref. (given prevalence in this thread) it is my understanding that

    Please Login or Register  to view this content.
    is slower than

    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    06-10-2008
    Posts
    14

    Re: Transfer Array data to Spreadsheet

    Yes, that is the concept. I just need to digest it and use it in my code!

    Is it possible to use 'Cells' instead of [range].resize?

    e.g. [a1].resize to cells(1,1).resize

    Thank you for your help!

  9. #9
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Transfer Array data to Spreadsheet

    Yes, see syntax in post prior to Phil_V

  10. #10
    Forum Contributor
    Join Date
    02-23-2006
    Location
    Near London, England
    MS-Off Ver
    Office 2003
    Posts
    770

    Re: Transfer Array data to Spreadsheet

    Quote Originally Posted by wjones View Post
    Yes, that is the concept. I just need to digest it and use it in my code!

    Is it possible to use 'Cells' instead of [range].resize?

    e.g. [a1].resize to cells(1,1).resize

    Thank you for your help!
    YES

    In fact I would normally use "cells(1,1)", but decided to use the [a1] format as that was what you seemed to have used

    The code altered would be:
    Please Login or Register  to view this content.

+ 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