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!
Bookmarks