+ Reply to Thread
Results 1 to 5 of 5

Array to worksheet range

  1. #1
    Registered User
    Join Date
    12-02-2011
    Location
    Goodyear, AZ
    MS-Off Ver
    Excel 2010
    Posts
    26

    Array to worksheet range

    I'm stumped with a small block of code which writes an array to a worksheet range. The array contains 172 rows of 2 columns consisting of dates and values. The resized range contains 172 rows of 2 columns.

    The result of execution is that row 1 of the worksheet is empty, column A of the worksheet is empty, column B of the range worksheet contains the array dates, the array values column is lost, and the 172nd row in the array is lost. It looks like the output is being offset by 1 row and 1 column which puzzles me.

    This is a summary of the code and the results displayed in the Intermediate window. I've been kicking on this for two days and need another set of eyes. Thank you.

    Earl Adamy

    1) displays Worksheet name
    2) varrDivHistoryWithFuture - displays size and first last contents
    3) rQSDivHistory (worksheet range) - displays size and first last contents
    4) clears the worksheet
    5) rQSDivHistory - resizes range to size of array
    6) sets rQSDivHistory.value = varrDivHistoryWithFuture
    7) rQSDivHistory - displays size and first last contents


    Please Login or Register  to view this content.

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

    Re: Array to worksheet range

    Eh, could you post the actual code?
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    12-02-2011
    Location
    Goodyear, AZ
    MS-Off Ver
    Excel 2010
    Posts
    26

    Re: Array to worksheet range

    I believe that I included all of the relevant code in my question; however this is the entire sub for anyone willing to wade through it. Earl

    Please Login or Register  to view this content.

  4. #4
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Array to worksheet range

    Hi,

    I suspect your array is in fact 0 based and therefore you are populating it offset by one row and column from where you expect.
    Don
    Please remember to mark your thread 'Solved' when appropriate.

  5. #5
    Registered User
    Join Date
    12-02-2011
    Location
    Goodyear, AZ
    MS-Off Ver
    Excel 2010
    Posts
    26

    Re: Array to worksheet range

    When I read your note, my first reaction was that it couldn't be because I use Option Base 1 in all of my modules. However it was easy enough to add the lower bound to the debug.print statements which proved you are correct:

    Please Login or Register  to view this content.
    It is interesting that I had verified UBound without verifying LBound due to the strength of my assumption regarding Option Base 1. Failing to explicitly specify the lower bound in Redim statements has been a long time bad habit used in some huge projects with hundreds of dynamic arrays. Amazingly, this is the first time this has bitten.

    I thank you for great job with "another set of eyes"!

    Earl Adamy

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Array to worksheet range - getting zeros instead of dates
    By eadamy in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-08-2015, 06:13 PM
  2. [SOLVED] Transferring an array to a range without selecting target worksheet
    By zebby in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-09-2014, 03:16 PM
  3. Replies: 1
    Last Post: 09-25-2013, 07:22 AM
  4. [SOLVED] Posting only a specific section of an array to worksheet range?
    By mc84excel in forum Excel Programming / VBA / Macros
    Replies: 19
    Last Post: 05-02-2013, 11:21 PM
  5. Help depurate this macro with Array in other worksheet range.
    By feroguz in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-20-2012, 12:48 PM
  6. Set array= range, and using a variable name for a worksheet
    By Keruck in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-18-2008, 11:55 AM
  7. Loading Worksheet Range to VBA Array
    By JohanF in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-08-2007, 06:54 AM

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