+ Reply to Thread
Results 1 to 4 of 4

Data to be copied from Worksheet into Array gives error 1004

  1. #1
    Registered User
    Join Date
    12-06-2012
    Location
    Sydney
    MS-Off Ver
    Excel 2007
    Posts
    2

    Data to be copied from Worksheet into Array gives error 1004

    Hi,

    Would someone please help me?

    I'm trying to copy data from a worksheet into a dynamic array that I wish to manipulate and then put into another Worksheet but get an error that I can't figure out.
    I try via myArray = Sht.Range("A1:H17").Value and it works
    but when I try to make it dynamic via myArray = Sht.Range(Cells(1, 1), Cells(LastRow, LastCol)).Value it fails! What am I doing wrong?
    Full details in code :

    Please Login or Register  to view this content.
    Thanks

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

    Re: Data to be copied from Worksheet into Array gives error 1004

    Please Login or Register  to view this content.
    is correct (No error) with 17 as lower bound and 8 as upper bound.
    It is probably Sht cells(1,1) is blank, hence the error.
    Last edited by AB33; 07-31-2013 at 12:39 PM.

  3. #3
    Forum Expert MickG's Avatar
    Join Date
    11-23-2007
    Location
    Banbury,Oxfordshire
    Posts
    2,650

    Re: Data to be copied from Worksheet into Array gives error 1004

    Try this:-
    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    12-06-2012
    Location
    Sydney
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: Data to be copied from Worksheet into Array gives error 1004

    Thanks to you both for your responses and as a result I've found the problem which seems like a bug in the vba.

    Please Login or Register  to view this content.
    works without error irrespective of which Sheet is Active

    as does
    Please Login or Register  to view this content.
    (Thanks MickG)

    My original code of
    Please Login or Register  to view this content.
    works ONLY if Sheet2 is Active and gives the error if not.

    I'm now very happy as this has be bugging me for days.
    Last edited by Inventiveman; 07-31-2013 at 11:52 PM.

+ 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. macro to enter array formula not working get error 1004
    By bkwins in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-07-2013, 06:52 AM
  2. Pasting copied data into worksheet giving error
    By jshaw82 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 05-05-2013, 04:57 PM
  3. Excel Macro Error - Run time error 1004 - Paste method of worksheet class failed
    By kvflynn in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-15-2012, 10:51 AM
  4. Comparing a string to values in an array resulting in a Run time Error 1004
    By sgreni in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-15-2009, 04:21 PM
  5. Error 1004 using array in Sheet select.
    By Trefor in forum Excel General
    Replies: 4
    Last Post: 09-07-2005, 03:05 PM

Tags for this Thread

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