Copy & Paste all from all workbooks in a folder to new worksheet

sjk1193

New Member
Joined
Nov 12, 2018
Messages
29
Hi there,

I need to specify a date and if it matches a date in column A in a different workbook I need to copy the whole row and paste it in a different workbook, and then loop through and copy/paste. Ideally I need to cycle through all workbooks in the same folder and copy paste from each of them.

Cross post: https://www.excelforum.com/excel-pr...1262086-copy-and-paste-based-on-date-vba.html

So far I have the code below but for some reason its not copying or pasting

Code:
Sub CopyRows()


Dim InputFile As Workbook
Dim OutputFile As Workbook
Dim myDate As Variant
Dim lr2 As Long
Dim i As Long




Set OutputFile = ThisWorkbook
Set InputFile = Workbooks.Open("S:\xxxxx\xxxx.xlsx")






myDate = InputBox("Enter Date    (mm/dd/yyyy)")




InputFile.Sheets(1).Activate


For i = 3 To Cells(Rows.Count, 1).End(xlUp).Row
    If myDate = Sheets(1).Cells(i, 1) Then
        'If Sheet1.Cells(i, 1).Value = myDate Then
        Rows(i).EntireRow.Copy
        
        OutputFile.Sheets(1).Activate
            lr2 = Sheet1.Cells(Rows.Count, 1).End(xlUp).Row + 1
            Cells(NextRow, 1).Select
            ActiveSheet.Paste
        
        InputFile.Sheets(1).Activate
        
    End If
         
Next i


End Sub
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.

Forum statistics

Threads
1,223,893
Messages
6,175,240
Members
452,621
Latest member
Laura_PinksBTHFT

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top