+ Reply to Thread
Results 1 to 7 of 7

Error putting horizontal series of cells into array .....why?

  1. #1
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,679

    Error putting horizontal series of cells into array .....why?

    I have the folllowing code which is supposed to put cells B2 through B25 into an array.


    Please Login or Register  to view this content.

    But it does not work............what does work is the following:


    Please Login or Register  to view this content.


    but i dont know why the 2nd worked but the first did not? anyone have any ideas?
    Last edited by welchs101; 09-23-2011 at 10:37 AM.

  2. #2
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Error putting horizontal series of cells into array .....why?

    Those two ranges are the not the same the first M2:Y2.

  3. #3
    Forum Expert
    Join Date
    07-16-2010
    Location
    Northumberland, UK
    MS-Off Ver
    Excel 2007 (home), Excel 2010 (work)
    Posts
    3,054

    Re: Error putting horizontal series of cells into array .....why?

    Is month_array1 declared as a variant?

  4. #4
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,679

    Re: Error putting horizontal series of cells into array .....why?

    Mistake on my part the two ranges are as follows:


    Please Login or Register  to view this content.
    Now the ranges should be the same but again month_array1 has a runtime error.

    I defined both month_array1 and month_array2 the same as variants such as this

    Please Login or Register  to view this content.
    I still dont know why the first one does not work.

  5. #5
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,679

    Re: Error putting horizontal series of cells into array .....why?

    Duh............ok........i am an idiot.

    Ok. B2 to B25 is obviously not the same as Cells(2,13) through Cells(2,25).

  6. #6
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,679

    Re: Error putting horizontal series of cells into array .....why?

    both seem to work now..........

    Please Login or Register  to view this content.

  7. #7
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: Error putting horizontal series of cells into array .....why?

    Plus, you may need to declare the sheet associated to the cells like
    Please Login or Register  to view this content.
    If you're happy with someone's help, click that little star at the bottom left of their post to give them Reps.

    ---Keep on Coding in the Free World---

+ 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