Results 1 to 3 of 3

Macro to Open File/s and copy data won't work

Threaded View

  1. #1
    Forum Contributor
    Join Date
    07-12-2018
    Location
    South Africa
    MS-Off Ver
    Office 2021
    Posts
    2,762

    Macro to Open File/s and copy data won't work

    I have written code to open data and select a file/s and then to copy the data from sheet1 to sheet imported data

    When running the macro, I get run time error-Application defined or object defined error

    The following part of the code is highlighted

     .Sheets(1).UsedRange.Copy Destination:=ThisWorkbook.Sheets("Imported Data").Range("A" & Rows.Count).End(xlUp).Offset(1)

    See full code below


     Sub Open_Workbook()
    
    
    A:
    Dim A     As Variant
        
        ChDir "C:\extract"
        A = Application.GetOpenFilename
        If A = False Or IsEmpty(A) Then Exit Sub
        
        Application.ScreenUpdating = False
          With Workbooks.Open(A)
            .Sheets(1).UsedRange.Copy Destination:=ThisWorkbook.Sheets("Imported Data").Range("A" & Rows.Count).End(xlUp).Offset(1)
            .Close False
        End With
        
       answer = MsgBox("Does another file needs to be selected?", vbYesNo + vbQuestion, "Hello")
    If answer = vbYes Then
    GoTo A:
    End If
     Application.ScreenUpdating = True
    End Sub


    I have attached my destination workbook containing the macro "Import Payment Data.xls" as well as my source workbook

    It would be appreciated if someone could assist me
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Macro to open file, filter data and copy to another workbook/sheets
    By mati_WAR in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-28-2017, 10:09 AM
  2. Macro open a file and copy the data
    By Mr.India in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-07-2015, 10:33 PM
  3. [SOLVED] cannot work out how to open a .chm help file in a macro
    By jmac1947 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-03-2014, 06:17 AM
  4. [SOLVED] Macro to copy the data from a closed file to another work book using filters
    By Kiran Kurapati in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-26-2014, 12:50 PM
  5. [SOLVED] open variably named file, copy/paste data into consolidation file, open next file in list
    By sllawrence1968 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-29-2012, 09:49 PM
  6. Open Separate File, Copy Data and Paste Macro
    By boohah in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-31-2010, 02:04 PM
  7. Macro to Open File & Copy Data
    By jamesryan in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-21-2008, 10:19 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