+ Reply to Thread
Results 1 to 5 of 5

Run-time error '1004': VBA code fails to read and copy data from the files

  1. #1
    Registered User
    Join Date
    02-13-2011
    Location
    Mlebourne
    MS-Off Ver
    Excel 2003
    Posts
    9

    Run-time error '1004': VBA code fails to read and copy data from the files

    Hi

    I've copied the code for looping through the files in the folder from a web site and included my own code to capture the data from the worksheets.Initially, it worked find when I was reading data from multiple sheets and write in row-wise in one sheet.Then I changed the code to write column-wise and the error starting to pop-up - Run-time error '1004':Application-define or object-defined error.And now its giving the same error for row-wise writing data.

    It may be simple thing but it is giving me a lot of grief.

    Please refer to the code below and many thanks in advance.
    Please Login or Register  to view this content.
    Last edited by mshaji; 05-03-2019 at 01:21 AM.

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Run-time error '1004': VBA code fails to read and copy data from the files

    When the error occurs, select Debug. Which line of code is highlighted?

    What parts of the code did you change?
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Registered User
    Join Date
    02-13-2011
    Location
    Mlebourne
    MS-Off Ver
    Excel 2003
    Posts
    9

    Re: Run-time error '1004': VBA code fails to read and copy data from the files

    Thanks for the reply - Jeff.

    When the error occurs, select Debug. Which line of code is highlighted?


    The select debug button will not appear on the error pop-up message.'Ok' and 'Help' buttons are displayed which do not highlight the failing code.

    What parts of the code did you change?
    I only included the code as below.Rest of code from the website - thespreadsheetguru is not changed.

    Please Login or Register  to view this content.

  4. #4
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Run-time error '1004': VBA code fails to read and copy data from the files

    I can't see any issues in the code. It's been a while since I've been here, is this still a problem? Can you attach the file? The paper clip icon does not work for attachments. To attach a file, under the text box where you type your reply click the Go Advanced button. On the next screen scroll down and click on Manage Attachments, which will show a pop-up window to Select and Upload a file. Then close the window.

  5. #5
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,885

    Re: Run-time error '1004': VBA code fails to read and copy data from the files

    Try checking what value variable "j" holds when the error is generated (either by stepping through, or using Debug.Print).
    My suspicion is that it holds some invalid value (string, 0 etc), since it's supplied by Inputbox.
    ?Progress isn't made by early risers. It's made by lazy men trying to find easier ways to do something.?
    ― Robert A. Heinlein

+ 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. Copy Data outside Excel and PasteSpecial inside Worksheet - Run-time error '1004'
    By deisouss in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 03-17-2021, 02:27 AM
  2. Replies: 0
    Last Post: 03-05-2019, 03:14 PM
  3. creating hyperlinks fails after row 65530 with run time error 1004
    By dschmitt in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-09-2017, 05:00 AM
  4. VBA Code...error = run time error 1004 autofilter method of range class failed
    By Dariusd7 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 11-15-2013, 04:49 PM
  5. Code fails with error 1004
    By cdjones in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 09-22-2010, 06:27 PM
  6. Macro fails at pasting (Run-time error '1004' Paste method fail)
    By SergioS in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 04-09-2010, 02:17 PM
  7. Run time error 1004-print files
    By Brad in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 05-03-2005, 10:06 AM

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