+ Reply to Thread
Results 1 to 9 of 9

Paste array to range

  1. #1
    Forum Contributor Bob@Sun's Avatar
    Join Date
    09-03-2009
    Location
    Montuak, Usa
    MS-Off Ver
    Excel 2007
    Posts
    438

    Paste array to range

    Hello,

    I have a dynamic array which I need to paste in excel

    Please Login or Register  to view this content.

    How can I do that?

    Thanks,
    BK

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

    Re: Paste array to range

    You can use UBound (& LBound where nec.)

    Please Login or Register  to view this content.
    If you know you will always use Base 1 then:

    Please Login or Register  to view this content.
    Last edited by DonkeyOte; 02-02-2011 at 06:35 AM. Reason: typo - last ref in first code should have been L rather than U

  3. #3
    Forum Contributor Bob@Sun's Avatar
    Join Date
    09-03-2009
    Location
    Montuak, Usa
    MS-Off Ver
    Excel 2007
    Posts
    438

    Re: Paste array to range

    The problem is that using Ubound gives me always 7 as the array is defined like this:

    a(1 to 7 , 1 to i)

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

    Re: Paste array to range

    Not if you specify the dimension it doesn't (it defaults to dimension 1 if unspecified)

    Did you test the example ?

  5. #5
    Forum Contributor Bob@Sun's Avatar
    Join Date
    09-03-2009
    Location
    Montuak, Usa
    MS-Off Ver
    Excel 2007
    Posts
    438

    Re: Paste array to range

    I tested it but could not make it to work.

    Attached is a sample file. You can see the array how it is assigned, could you please paste it as I have shown in the excel?

    Thanks
    BK
    Attached Files Attached Files

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

    Re: Paste array to range

    If you're trying to return the 7x2 array to 2x7 range then you will need to transpose the Array and invert the Ubounds, eg:

    Please Login or Register  to view this content.
    I am presuming this is a hypothetical scenario given the way the Array is being populated...

    (and again, the above is assuming Option Base 1 at all times re: a)

  7. #7
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Paste array to range

    Please Login or Register  to view this content.



  8. #8
    Forum Contributor Bob@Sun's Avatar
    Join Date
    09-03-2009
    Location
    Montuak, Usa
    MS-Off Ver
    Excel 2007
    Posts
    438

    Re: Paste array to range

    Thanks a lot, this is working as expected now.

    One question though, what means that the code is assuming Option Base 1 at all times?

    Thanks again

    BK

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

    Re: Paste array to range

    see VBE Help re: Option Base

+ 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