Hello,
I have the following code, which will bring in data from different workbooks. It will now bring in the data, but will paste over the previous data. I tried to make it so that it will copy just the data from the tabs and paste it all under one another. Also, I need to be able to just take the information from a specific tab, but when I put in something like
it comes back with an error. I have posted to code below, but I have also attached the files. Thank you.
Sub Consolidate()
Dim fName As String, fPath As String, fPathDone As String, OldDir As String
Dim LR As Long, LR1 As Long, LR2 As Long, LR3 As Long, NR As Long, NR1 As Long, NR2 As Long
Dim wbData As Workbook, wbkNew As Workbook, wbData1 As Workbook, wbData2 As Workbook
'Setup
Application.ScreenUpdating = False
Application.EnableEvents = False
Application.DisplayAlerts = False
Set wbkNew = ThisWorkbook
wbkNew.Activate
'Path and filename (edit this section to suit)
fPathDone = fPath & "Imported\" 'remember final \ in this string
On Error Resume Next
MkDir fPathDone 'creates the completed folder if missing
On Error GoTo 0
OldDir = CurDir 'memorizes the users current working path
Set wbData = Workbooks.Open("C:\Documents and Settings\jchmielinski\Desktop\Data\Book1.xlsx")
'Sheets("Sheet1").Select
NR = Range("A" & Rows.Count).End(xlUp).Row + 1
LR1 = Range("A" & Rows.Count).End(xlUp).Row
Range("A1:A" & LR1).EntireRow.Copy _
wbkNew.Sheets("Sheet1").Range("A" & 1)
LastRow = Cells(Rows.Count, 1).End(xlUp).Row
Set wbData1 = Workbooks.Open("C:\Documents and Settings\jchmielinski\Desktop\Data\Book2.xlsx")
NR1 = Range("A" & Rows.Count).End(xlUp).Row + 1
LR2 = Range("A" & Rows.Count).End(xlUp).Row
Range("A2:A" & LastRow).EntireRow.Copy _
wbkNew.Sheets("Sheet1").Range("A" & NR)
LastRow1 = Cells(Rows.Count, 1).End(xlUp).Row
Set wbData2 = Workbooks.Open("C:\Documents and Settings\jchmielinski\Desktop\Data\Book3.xlsx")
NR2 = Range("A" & Rows.Count).End(xlUp).Row + 1
LR3 = Range("A" & Rows.Count).End(xlUp).Row
Range("A2:A" & LastRow1).EntireRow.Copy _
wbkNew.Sheets("Sheet1").Range("A" & NR1)
ErrorExit: 'Cleanup
ActiveSheet.Columns.AutoFit
Application.DisplayAlerts = True 'turn system alerts back on
Application.EnableEvents = True 'turn other macros back on
Application.ScreenUpdating = True 'refreshes the screen
ChDir OldDir 'restores users original working path
End Sub
Bookmarks