+ Reply to Thread
Results 1 to 3 of 3

Folder Copy/Paste Looping

  1. #1
    Registered User
    Join Date
    06-17-2014
    Location
    Ohio
    MS-Off Ver
    MSO 2010
    Posts
    8

    Folder Copy/Paste Looping

    Hi! I had this macro working but something got deleted and I am trying to figure out why it is no longer running. What is does (or is supposed to do) is it open's each file and copies it's contents and pastes it into Sheet1 of the master file after the last row of the previously pasted data. Right now, I am getting an error User Defined error (1004) and it's occurring when I attempt to set the workbook to open from the file. Below is my code:

    Sub GetMyPricingData()
    Dim folderpath As String, Path As String, openwrk as workbook
    folderpath = "C:\Users\user"
    Path = folderpath & "\*.csv"
    Filename = Dir(Path)
    Do While Filename <> ""
    Set openwrk = Workbooks.Open(Filename)
    openwrk.Activate
    LastRow = ActiveSheet.UsedRange.SpecialCells(xlLastCell).Row
    ActiveSheet.Range("A1:O" & LastRow).Copy
    Set importd = Workbooks("Import Data Workbook.xlsm").Worksheets("Sheet1")
    importd.Activate
    LastRow_data = (ActiveSheet.UsedRange.SpecialCells(xlLastCell).Row) + 1
    Workbooks("Import Data Workbook.xlsm").ActiveSheet.Range("A" & LastRow_data, "O" & LastRow_data).PasteSpecial (xlPasteValues)
    'importd.Worksheets("Sheet1").Range("A" & LastRow_data, "O" & LastRow_data).PasteSpecial (xlPasteValues)
    Application.DisplayAlerts = False
    openwrk.Close
    Filename = Dir
    Loop
    MsgBox "All Data Imported!"
    ActiveWorkbook.Save
    MsgBox "Data Has Been Saved!"
    End Sub

    Any help is very appreciated!

    Thanks!

  2. #2
    Registered User
    Join Date
    06-17-2014
    Location
    Ohio
    MS-Off Ver
    MSO 2010
    Posts
    8

    Re: Folder Copy/Paste Looping

    To The Top!!

  3. #3
    Registered User
    Join Date
    06-17-2014
    Location
    Ohio
    MS-Off Ver
    MSO 2010
    Posts
    8

    Re: Folder Copy/Paste Looping

    Figured it out! Solved

+ 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. Macros Open folder, copy, paste and close the folder
    By hahahahahahaha in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-10-2013, 05:03 PM
  2. [SOLVED] Help with Looping a copy and paste marco
    By Robert110 in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 03-26-2013, 11:02 AM
  3. search for a file in a folder based on data, copy and paste it in another folder
    By kboy1289 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-05-2013, 11:47 AM
  4. [SOLVED] VBA Looping Copy and Paste
    By harrison298 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-11-2012, 11:43 AM
  5. Copy folder and paste to another folder
    By ddiicc in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-21-2005, 09:47 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