+ Reply to Thread
Results 1 to 4 of 4

Printing an array to another sheet.

  1. #1
    Registered User
    Join Date
    07-20-2010
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    59

    Printing an array to another sheet.

    Hoping someone here can help me.

    The following code is generating a run-time error 9. What is my problem here? The loop to generate the array is working fine but I just want to print the array to another sheet.

    r = 2

    For i = 1 To UBound (aZips) - 1

    Sheets("Sheet2").Cells(r, 5) = aZips(i)

    r = r + 1

    Next i


    Many thanks in advance.

  2. #2
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: Printing an array to another sheet.

    Syntactically the code is correct. You may run into issues using uBound() - 1 as arrays are 0 based by default.

    The only reason for an error 9 I can think of, in the code as posted, is that a worksheet named Sheet2 does not exist...

  3. #3
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Printing an array to another sheet.

    This is my guess(ONLY Guess)
    You loaded your data in to array-aZips. Now you are looping through the array and want to write it back to range. I think you need to redim it and put the value of the loop in to the redim variant before you print back to sheet2

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643
    Andrew

    How have you declared/created the array aZips?

    Is it definitely a one dimensional array?
    If posting code please use code tags, see here.

+ 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